失败告警策略扩展:默认提供邮件失败告警,可扩展短信等,扩展代码位置为 "JobFailMonitorHelper.failAlarm";

This commit is contained in:
xuxueli 2017-10-11 21:27:21 +08:00
parent ed31b1b66a
commit b7a2724f11
2 changed files with 11 additions and 4 deletions

View File

@ -1021,6 +1021,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
### 6.20 版本 V1.9.0 特性[迭代中] ### 6.20 版本 V1.9.0 特性[迭代中]
- 1、新增任务运行模式 "GLUE模式(NodeJS) "支持NodeJS脚本任务 - 1、新增任务运行模式 "GLUE模式(NodeJS) "支持NodeJS脚本任务
- 2、修复任务监控线程被耗时任务阻塞的问题 - 2、修复任务监控线程被耗时任务阻塞的问题
- 3、失败告警策略扩展默认提供邮件失败告警可扩展短信等扩展代码位置为 "JobFailMonitorHelper.failAlarm"
### TODO LIST ### TODO LIST
- 1、任务权限管理执行器为粒度分配权限核心操作校验权限 - 1、任务权限管理执行器为粒度分配权限核心操作校验权限

View File

@ -61,7 +61,7 @@ public class JobFailMonitorHelper {
} }
if (ReturnT.FAIL_CODE == log.getTriggerCode() || ReturnT.FAIL_CODE == log.getHandleCode()) { if (ReturnT.FAIL_CODE == log.getTriggerCode() || ReturnT.FAIL_CODE == log.getHandleCode()) {
// job fail, // job fail,
sendMonitorEmail(log); failAlarm(log);
logger.info(">>>>>>>>>>> job monitor, job fail, JobLogId:{}", jobLogId); logger.info(">>>>>>>>>>> job monitor, job fail, JobLogId:{}", jobLogId);
} }
} }
@ -81,7 +81,7 @@ public class JobFailMonitorHelper {
XxlJobLog log = XxlJobDynamicScheduler.xxlJobLogDao.load(jobLogId); XxlJobLog log = XxlJobDynamicScheduler.xxlJobLogDao.load(jobLogId);
if (ReturnT.FAIL_CODE == log.getTriggerCode()|| ReturnT.FAIL_CODE==log.getHandleCode()) { if (ReturnT.FAIL_CODE == log.getTriggerCode()|| ReturnT.FAIL_CODE==log.getHandleCode()) {
// job fail, // job fail,
sendMonitorEmail(log); failAlarm(log);
logger.info(">>>>>>>>>>> job monitor last, job fail, JobLogId:{}", jobLogId); logger.info(">>>>>>>>>>> job monitor last, job fail, JobLogId:{}", jobLogId);
} }
} }
@ -94,10 +94,13 @@ public class JobFailMonitorHelper {
} }
/** /**
* send monitor email * fail alarm
*
* @param jobLog * @param jobLog
*/ */
private void sendMonitorEmail(XxlJobLog jobLog){ private void failAlarm(XxlJobLog jobLog){
// send monitor email
XxlJobInfo info = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobLog.getJobId()); XxlJobInfo info = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobLog.getJobId());
if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) { 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); MailUtil.sendMail(email, title, content, false, null);
} }
} }
// TODO, custom alarm strategy, such as sms
} }
public void toStop(){ public void toStop(){