|
|
@ -193,25 +193,40 @@ public final class XxlJobDynamicScheduler implements ApplicationContextAware, In
|
|
|
|
|
|
|
|
|
|
|
|
// TriggerKey : name + group
|
|
|
|
// TriggerKey : name + group
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName, jobGroup);
|
|
|
|
TriggerKey triggerKey = TriggerKey.triggerKey(jobName, jobGroup);
|
|
|
|
JobKey jobKey = new JobKey(jobName, jobGroup);
|
|
|
|
CronTrigger oldTrigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
|
|
|
|
|
|
|
|
|
|
|
// CronTrigger : TriggerKey + cronExpression
|
|
|
|
if (oldTrigger != null) {
|
|
|
|
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing();
|
|
|
|
// avoid repeat
|
|
|
|
CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();
|
|
|
|
String oldCron = oldTrigger.getCronExpression();
|
|
|
|
|
|
|
|
if (oldCron.equals(cronExpression)){
|
|
|
|
//scheduler.rescheduleJob(triggerKey, cronTrigger);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
// JobDetail-JobDataMap fresh
|
|
|
|
|
|
|
|
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
|
|
|
|
// CronTrigger : TriggerKey + cronExpression
|
|
|
|
/*JobDataMap jobDataMap = jobDetail.getJobDataMap();
|
|
|
|
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing();
|
|
|
|
jobDataMap.clear();
|
|
|
|
oldTrigger = oldTrigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();
|
|
|
|
jobDataMap.putAll(JacksonUtil.readValue(jobInfo.getJobData(), Map.class));*/
|
|
|
|
|
|
|
|
|
|
|
|
// rescheduleJob
|
|
|
|
// Trigger fresh
|
|
|
|
scheduler.rescheduleJob(triggerKey, oldTrigger);
|
|
|
|
HashSet<Trigger> triggerSet = new HashSet<Trigger>();
|
|
|
|
} else {
|
|
|
|
triggerSet.add(cronTrigger);
|
|
|
|
// CronTrigger : TriggerKey + cronExpression
|
|
|
|
|
|
|
|
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing();
|
|
|
|
scheduler.scheduleJob(jobDetail, triggerSet, true);
|
|
|
|
CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// JobDetail-JobDataMap fresh
|
|
|
|
|
|
|
|
JobKey jobKey = new JobKey(jobName, jobGroup);
|
|
|
|
|
|
|
|
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
|
|
|
|
|
|
|
|
/*JobDataMap jobDataMap = jobDetail.getJobDataMap();
|
|
|
|
|
|
|
|
jobDataMap.clear();
|
|
|
|
|
|
|
|
jobDataMap.putAll(JacksonUtil.readValue(jobInfo.getJobData(), Map.class));*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Trigger fresh
|
|
|
|
|
|
|
|
HashSet<Trigger> triggerSet = new HashSet<Trigger>();
|
|
|
|
|
|
|
|
triggerSet.add(cronTrigger);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scheduler.scheduleJob(jobDetail, triggerSet, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
logger.info(">>>>>>>>>>> resumeJob success, JobGroup:{}, JobName:{}", jobGroup, jobName);
|
|
|
|
logger.info(">>>>>>>>>>> resumeJob success, JobGroup:{}, JobName:{}", jobGroup, jobName);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|