diff --git a/xxl-job-admin/pom.xml b/xxl-job-admin/pom.xml
index bfa25fe9..192e6e64 100644
--- a/xxl-job-admin/pom.xml
+++ b/xxl-job-admin/pom.xml
@@ -130,6 +130,13 @@
4.3.6
+
+
+ javax.mail
+ mail
+ 1.4.6
+
+
org.quartz-scheduler
diff --git a/xxl-job-admin/src/main/java/com/xxl/job/core/resolver/WebExceptionResolver.java b/xxl-job-admin/src/main/java/com/xxl/job/controller/resolver/WebExceptionResolver.java
similarity index 94%
rename from xxl-job-admin/src/main/java/com/xxl/job/core/resolver/WebExceptionResolver.java
rename to xxl-job-admin/src/main/java/com/xxl/job/controller/resolver/WebExceptionResolver.java
index 3bc58d7f..9060e28c 100644
--- a/xxl-job-admin/src/main/java/com/xxl/job/core/resolver/WebExceptionResolver.java
+++ b/xxl-job-admin/src/main/java/com/xxl/job/controller/resolver/WebExceptionResolver.java
@@ -1,4 +1,4 @@
-package com.xxl.job.core.resolver;
+package com.xxl.job.controller.resolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
diff --git a/xxl-job-admin/src/main/java/com/xxl/job/core/thread/JobMonitorHelper.java b/xxl-job-admin/src/main/java/com/xxl/job/core/thread/JobMonitorHelper.java
new file mode 100644
index 00000000..c322d9c4
--- /dev/null
+++ b/xxl-job-admin/src/main/java/com/xxl/job/core/thread/JobMonitorHelper.java
@@ -0,0 +1,82 @@
+package com.xxl.job.core.thread;
+
+import java.text.MessageFormat;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.xxl.job.client.util.HttpUtil;
+import com.xxl.job.core.model.XxlJobInfo;
+import com.xxl.job.core.model.XxlJobLog;
+import com.xxl.job.core.util.DynamicSchedulerUtil;
+import com.xxl.job.core.util.MailUtil;
+
+/**
+ * job monitor helper
+ * @author xuxueli 2015-9-1 18:05:56
+ */
+public class JobMonitorHelper {
+ private static Logger logger = LoggerFactory.getLogger(JobMonitorHelper.class);
+
+ public static JobMonitorHelper helper = new JobMonitorHelper();
+ private ExecutorService executor = Executors.newCachedThreadPool();
+ private LinkedBlockingQueue queue = new LinkedBlockingQueue(0xfff8);
+ private ConcurrentHashMap countMap = new ConcurrentHashMap();
+
+ public JobMonitorHelper(){
+ // consumer
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ logger.info(">>>>>>>>>>> job monitor run ... ");
+ Integer jobLogId = JobMonitorHelper.helper.queue.poll();
+ if (jobLogId != null && jobLogId > 0) {
+ XxlJobLog log = DynamicSchedulerUtil.xxlJobLogDao.load(jobLogId);
+ if (log!=null) {
+ if (HttpUtil.SUCCESS.equals(log.getTriggerStatus()) && StringUtils.isBlank(log.getHandleStatus())) {
+ JobMonitorHelper.monitor(jobLogId);
+ }
+ if (HttpUtil.SUCCESS.equals(log.getTriggerStatus()) && HttpUtil.SUCCESS.equals(log.getHandleStatus())) {
+ // pass
+ }
+ if (HttpUtil.FAIL.equals(log.getTriggerStatus()) || HttpUtil.FAIL.equals(log.getHandleStatus())) {
+ String monotorKey = log.getJobGroup().concat("_").concat(log.getJobName());
+ Integer count = countMap.get(monotorKey);
+ if (count == null) {
+ count = new Integer(0);
+ }
+ count += 1;
+ countMap.put(monotorKey, count);
+ XxlJobInfo info = DynamicSchedulerUtil.xxlJobInfoDao.load(log.getJobGroup(), log.getJobName());
+ if (count >= info.getAlarmThreshold()) {
+ MailUtil.sendMail(info.getAlarmEmail(), "《调度平台中心-监控报警》",
+ MessageFormat.format("调度任务[{0}]失败报警", monotorKey), false, null);
+ countMap.remove(monotorKey);
+ }
+ }
+ }
+ } else {
+ try {
+ TimeUnit.SECONDS.sleep(20);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ });
+ }
+
+ // producer
+ public static void monitor(int jobLogId){
+ JobMonitorHelper.helper.queue.offer(jobLogId);
+ }
+
+}
diff --git a/xxl-job-admin/src/main/java/com/xxl/job/core/util/DynamicSchedulerUtil.java b/xxl-job-admin/src/main/java/com/xxl/job/core/util/DynamicSchedulerUtil.java
index 1b06f653..ef675c72 100644
--- a/xxl-job-admin/src/main/java/com/xxl/job/core/util/DynamicSchedulerUtil.java
+++ b/xxl-job-admin/src/main/java/com/xxl/job/core/util/DynamicSchedulerUtil.java
@@ -67,6 +67,7 @@ public final class DynamicSchedulerUtil implements ApplicationContextAware, Init
}
// getJobKeys
+ @Deprecated
public static List