From b7a2724f1137f7e23a44a950470ec8df362da0fe Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Wed, 11 Oct 2017 21:27:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=91=8A=E8=AD=A6=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E6=89=A9=E5=B1=95=EF=BC=9A=E9=BB=98=E8=AE=A4=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E9=82=AE=E4=BB=B6=E5=A4=B1=E8=B4=A5=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=EF=BC=8C=E5=8F=AF=E6=89=A9=E5=B1=95=E7=9F=AD=E4=BF=A1=E7=AD=89?= =?UTF-8?q?=EF=BC=8C=E6=89=A9=E5=B1=95=E4=BB=A3=E7=A0=81=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=BA=20"JobFailMonitorHelper.failAlarm"=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/XXL-JOB官方文档.md | 1 + .../admin/core/thread/JobFailMonitorHelper.java | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index e6ebde76..13a15a6d 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -1021,6 +1021,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 ### 6.20 版本 V1.9.0 特性[迭代中] - 1、新增任务运行模式 "GLUE模式(NodeJS) ",支持NodeJS脚本任务; - 2、修复任务监控线程被耗时任务阻塞的问题; +- 3、失败告警策略扩展:默认提供邮件失败告警,可扩展短信等,扩展代码位置为 "JobFailMonitorHelper.failAlarm"; ### TODO LIST - 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java index c2a8b23e..797f1b1d 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java @@ -61,7 +61,7 @@ public class JobFailMonitorHelper { } if (ReturnT.FAIL_CODE == log.getTriggerCode() || ReturnT.FAIL_CODE == log.getHandleCode()) { // job fail, - sendMonitorEmail(log); + failAlarm(log); logger.info(">>>>>>>>>>> job monitor, job fail, JobLogId:{}", jobLogId); } } @@ -81,7 +81,7 @@ public class JobFailMonitorHelper { XxlJobLog log = XxlJobDynamicScheduler.xxlJobLogDao.load(jobLogId); if (ReturnT.FAIL_CODE == log.getTriggerCode()|| ReturnT.FAIL_CODE==log.getHandleCode()) { // job fail, - sendMonitorEmail(log); + failAlarm(log); logger.info(">>>>>>>>>>> job monitor last, job fail, JobLogId:{}", jobLogId); } } @@ -94,10 +94,13 @@ public class JobFailMonitorHelper { } /** - * send monitor email + * fail alarm + * * @param jobLog */ - private void sendMonitorEmail(XxlJobLog jobLog){ + private void failAlarm(XxlJobLog jobLog){ + + // send monitor email XxlJobInfo info = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobLog.getJobId()); if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) { @@ -109,6 +112,9 @@ public class JobFailMonitorHelper { MailUtil.sendMail(email, title, content, false, null); } } + + // TODO, custom alarm strategy, such as sms + } public void toStop(){