trigger:设置定时时间 常用的trigger:
SimpleTrigger:简单的触发器(个人理解间隔触发器)
CronTrigger:Cron表达式触发器
CalendarIntervalTrigger:日历触发器
DailyTimeIntervalTrigger:日期触发器
1.SimpleTrigger:
一 每隔一小时触发
SimpleScheduleBuilder.repeatHourlyForever(1)
二 misfire机制:
withMisfireHandlingInstructionFireNow
以当前时间为触发频率立即触发执行
执行至FinalTIme的剩余周期次数
以调度或恢复调度的时刻为基准的周期频率,FinalTime根据剩余次数和当前时间计算得到
调整后的FinalTime会略大于根据starttime计算的到的FinalTime值
withMisfireHandlingInstructionIgnoreMisfires
错过的全部执行,共执行RepeatCount+1次
withMisfireHandlingInstructionNextWithExistingCount
错过全部忽略,执行接下去的trigger
withMisfireHandlingInstructionNextWithRemainingCount
之前全部忽略,执行接下去的trigger
withMisfireHandlingInstructionNowWithExistingCount(默认)
立即执行一次,然后按照trigger继续执行
withMisfireHandlingInstructionNowWithRemainingCount
以当前时间为触发频率立即触发执行
执行至FinalTIme的剩余周期次数
以调度或恢复调度的时刻为基准的周期频率,FinalTime根据剩余次数和当前时间计算得到
调整后的FinalTime会略大于根据starttime计算的到的FinalTime值
2.CronTrigger:
一 每隔5秒触发一次
CronScheduleBuilder.cronSchedule(“0/5 * * * * * ?”)
二 misfire机制:
withMisfireHandlingInstructionDoNothing
错过的tirrger全部忽略,等待下次Cron触发频率到达时刻开始按照Cron频率依次执行
withMisfireHandlingInstructionIgnoreMisfires
错过的全部都执行,然后一直执行
withMisfireHandlingInstructionFireAndProceed(默认)
立即执行一次,然后按照Cron频率依次执行
2.DailyTimeIntervalTrigger:
DailyTimeIntervalScheduleBuilder.dailyTimeIntervalSchedule().withInterval(2, DateBuilder.IntervalUnit.MONTH);