1、调度重启后,取消补偿遗失调度;

2、延迟启动调度器;
3、支持调度非并发执行,默认并发(需要扩大线程数);
master
xueli.xue 9 years ago
parent 2540860e20
commit 51bfaa4131
  1. 6
      xxl-job-admin/src/main/java/com/xxl/job/core/util/DynamicSchedulerUtil.java
  2. 3
      xxl-job-admin/src/main/resources/applicationcontext-trigger-db.xml
  3. 10
      xxl-job-simple/src/main/java/com/xxl/job/service/job/DemoJobBean.java

@ -104,8 +104,8 @@ public final class DynamicSchedulerUtil implements InitializingBean {
return false;
}
// CronTrigger : TriggerKey + cronExpression
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
// CronTrigger : TriggerKey + cronExpression // withMisfireHandlingInstructionDoNothing 忽略掉调度终止过程中忽略的调度
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing();
CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();
// JobDetail : jobClass
@ -131,7 +131,7 @@ public final class DynamicSchedulerUtil implements InitializingBean {
boolean result = false;
if (scheduler.checkExists(triggerKey)) {
// CronTrigger : TriggerKey + cronExpression
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing();
CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();
Date date = scheduler.rescheduleJob(triggerKey, cronTrigger);

@ -11,7 +11,8 @@
<bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="autoStartup" value="true" />
<property name="autoStartup" value="true" /> <!--自动启动 -->
<property name="startupDelay" value="20" /> <!--延时启动 -->
<property name="applicationContextSchedulerContextKey" value="applicationContextKey" />
<property name="configLocation" value="classpath:quartz.properties"/>
</bean>

@ -3,7 +3,9 @@ package com.xxl.job.service.job;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
@ -14,6 +16,8 @@ import org.springframework.scheduling.quartz.QuartzJobBean;
* http job bean
* @author xuxueli 2015-12-17 18:20:34
*/
@DisallowConcurrentExecution // 取消并发执行;线程数要多配置几个,否则不生效;
public class DemoJobBean extends QuartzJobBean {
private static Logger logger = LoggerFactory.getLogger(DemoJobBean.class);
@ -33,6 +37,12 @@ public class DemoJobBean extends QuartzJobBean {
}
}
try {
TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
}
logger.info(">>>>>>>>>>> xxl-job run :jobId:{}, group:{}, jobDataMap:{}",
new Object[]{triggerKey, triggerGroup, jobDataMap});
}

Loading…
Cancel
Save