diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index 604c53e5..94691dc0 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -1215,7 +1215,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 ### 6.22 版本 V1.9.2 特性[迭代中] - 1、[迭代中]支持通过API服务操作任务信息; -- 2、[迭代中]任务告警逻辑调整:任务调度,以及任务回调失败时,均推送监控队列。后期考虑通过任务Log字段控制告警状态; +- 2、告警邮件中展示失败告警信息; - 3、任务超时控制:支持设置任务超时时间,任务运行超时的情况下,将会主动中断任务; - 4、任务属性枚举 "任务模式、阻塞策略" 国际化优化; - 5、任务日志表状态字段类型优化; @@ -1248,16 +1248,16 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 - 13、任务依赖增强,新增任务类型 "流程任务",流程节点可挂载普通类型任务,承担任务依赖功能。现有子任务模型取消;需要考虑任务依赖死循环问题; - 14、分片任务某一分片失败,支持分片转移; - 15、调度中心触发任务后,先推送触发队列,异步触发,然后立即返回。降低quartz线程占用时长。 -- 16、新增API服务 "XxlJobService" ,支持通过API服务来维护管理任务信息; +- 16、任务告警逻辑调整:任务调度,以及任务回调失败时,均推送监控队列。后期考虑通过任务Log字段控制告警状态; - 17、新增任务默认运行状态,任务更新时运行状态保持不变; -- 18、告警邮件中展示失败告警信息; -- 19、提供多版本执行器:不依赖容器版本、不内嵌Jetty版本(通过配置executoraddress替换jetty通讯)等; -- 20、注册中心支持扩展,除默认基于DB之外,支持扩展接入第三方注册中心如zk、eureka等; -- 21、依赖Core内部国际化处理; -- 22、故障转移、失败重试等策略,规范化合并归类; -- 23、流程任务,支持参数传递; -- 24、SimpleTrigger 支持; -- 25、springboot热部署支持; +- 18、提供多版本执行器:不依赖容器版本、不内嵌Jetty版本(通过配置executoraddress替换jetty通讯)等; +- 19、注册中心支持扩展,除默认基于DB之外,支持扩展接入第三方注册中心如zk、eureka等; +- 20、依赖Core内部国际化处理; +- 21、故障转移、失败重试等策略,规范化合并归类; +- 22、流程任务,支持参数传递; +- 23、SimpleTrigger 支持; +- 24、springboot热部署支持; + ## 七、其他 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 0d5ab6e3..35e414b1 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 @@ -125,10 +125,11 @@ public class JobFailMonitorHelper { "\n" + " " + " \n" + - " \n" + - " \n" + - " \n" + - " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -137,6 +138,7 @@ public class JobFailMonitorHelper { " \n" + " \n" + " \n" + + " \n" + " \n" + " \n" + "
"+ I18nUtil.getString("jobinfo_field_jobgroup") +""+ I18nUtil.getString("jobinfo_field_id") +""+ I18nUtil.getString("jobinfo_field_jobdesc") +""+ I18nUtil.getString("jobconf_monitor_alarm_title") +""+ I18nUtil.getString("jobinfo_field_jobgroup") +""+ I18nUtil.getString("jobinfo_field_id") +""+ I18nUtil.getString("jobinfo_field_jobdesc") +""+ I18nUtil.getString("jobconf_monitor_alarm_title") +""+ I18nUtil.getString("jobconf_monitor_alarm_content") +"
{1}{2}"+ I18nUtil.getString("jobconf_monitor_alarm_type") +"{3}
"; @@ -152,12 +154,24 @@ public class JobFailMonitorHelper { XxlJobInfo info = XxlJobDynamicScheduler.xxlJobInfoDao.loadById(jobLog.getJobId()); if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) { + String alarmContent = "Alarm Job LogId=" + jobLog.getId(); + if (jobLog.getTriggerCode() != ReturnT.SUCCESS_CODE) { + alarmContent += "
TriggerMsg=" + jobLog.getTriggerMsg(); + } + if (jobLog.getHandleCode()>0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) { + alarmContent += "
HandleCode=" + jobLog.getHandleMsg(); + } + Set emailSet = new HashSet(Arrays.asList(info.getAlarmEmail().split(","))); for (String email: emailSet) { XxlJobGroup group = XxlJobDynamicScheduler.xxlJobGroupDao.load(Integer.valueOf(info.getJobGroup())); String title = I18nUtil.getString("jobconf_monitor"); - String content = MessageFormat.format(mailBodyTemplate, group!=null?group.getTitle():"null", info.getId(), info.getJobDesc()); + String content = MessageFormat.format(mailBodyTemplate, + group!=null?group.getTitle():"null", + info.getId(), + info.getJobDesc(), + alarmContent); MailUtil.sendMail(email, title, content); } diff --git a/xxl-job-admin/src/main/resources/i18n/message.properties b/xxl-job-admin/src/main/resources/i18n/message.properties index 6381028d..c8ed627a 100644 --- a/xxl-job-admin/src/main/resources/i18n/message.properties +++ b/xxl-job-admin/src/main/resources/i18n/message.properties @@ -215,6 +215,7 @@ jobconf_monitor=调度中心监控报警 jobconf_monitor_detail=监控告警明细 jobconf_monitor_alarm_title=告警类型 jobconf_monitor_alarm_type=调度失败 +jobconf_monitor_alarm_content=告警内容 jobconf_trigger_admin_adress=调度机器 jobconf_trigger_exe_regtype=执行器-注册方式 jobconf_trigger_exe_regaddress=执行器-地址列表 diff --git a/xxl-job-admin/src/main/resources/i18n/message_en.properties b/xxl-job-admin/src/main/resources/i18n/message_en.properties index 47c6c47f..11e03855 100644 --- a/xxl-job-admin/src/main/resources/i18n/message_en.properties +++ b/xxl-job-admin/src/main/resources/i18n/message_en.properties @@ -215,6 +215,7 @@ jobconf_monitor=Scheduling Center monitor alarm jobconf_monitor_detail=monitor alarm details jobconf_monitor_alarm_title=Alarm Type jobconf_monitor_alarm_type=Trigger Fail +jobconf_monitor_alarm_content=Alarm Content jobconf_trigger_admin_adress=Trigger machine address jobconf_trigger_exe_regtype=Execotor-Registry Type jobconf_trigger_exe_regaddress=Execotor-Registry Address diff --git a/xxl-job-admin/src/test/java/com/xxl/job/admin/util/MailUtilTest.java b/xxl-job-admin/src/test/java/com/xxl/job/admin/util/MailUtilTest.java deleted file mode 100644 index b1d646f5..00000000 --- a/xxl-job-admin/src/test/java/com/xxl/job/admin/util/MailUtilTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.xxl.job.admin.util; - -import com.xxl.job.admin.core.util.MailUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.text.MessageFormat; - -/** - * email util test - * - * @author xuxueli 2017-12-22 17:16:23 - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml") -public class MailUtilTest { - - @Test - public void mailTest() throws Exception { - - String mailBodyTemplate = "
监控告警明细:" + - "\n" + - " " + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
执行器任务ID任务描述告警类型
{0}{1}{2}调度失败
"; - - String title = "调度中心监控报警"; - String content = MessageFormat.format(mailBodyTemplate, "执行器A", "01", "任务A1"); - - boolean ret = MailUtil.sendMail("931591021@qq.com", title, content); - System.out.println(ret); - } - -} diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/thread/JobThread.java b/xxl-job-core/src/main/java/com/xxl/job/core/thread/JobThread.java index fa268bfd..81b839a7 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/thread/JobThread.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/thread/JobThread.java @@ -143,7 +143,7 @@ public class JobThread extends Thread{ XxlJobLogger.log("
----------- xxl-job job execute timeout"); XxlJobLogger.log(e); - executeResult = new ReturnT(IJobHandler.FAIL_TIMEOUT.getCode(), "job execute timeout " + e.getMessage()); + executeResult = new ReturnT(IJobHandler.FAIL_TIMEOUT.getCode(), "job execute timeout "); } finally { futureThread.interrupt(); }