Grails Quartz 启动延迟不起作用
Grails Quartz startdelay doesn't work
我正在使用 Grails 2.4.5 和 plugin quartz 1.0.2。我的工作:
class NotWellpaidJob {
def staticaService
static triggers = {
cron name: 'cronTrigger',startDelay:3000, cronExpression: "0/20 58 16 ? * MON-FRI"
}
def execute() {
print new Date()
}
}
我的输出:
Thu Nov 19 16:58:00 CET 2015
Thu Nov 19 16:58:20 CET 2015
Thu Nov 19 16:58:40 CET 2015
问题:
为什么 startDelay 不会将第一次执行延迟 3 秒并且第一个日期时间不是 Thu Nov 19 16:58:03 CET 2015?
当您在 cron 触发器上设置 startDelay
时,插件实质上是在修改在 Quartz 中 CronTriggerImpl class 上传递给 setStartTime
的内容。
从Quartz documentation起,开始时间定义为:
The time at which the trigger's scheduling should start. May or may
not be the first actual fire time of the trigger, depending upon the
type of trigger and the settings of the other properties of the
trigger. However the first actual first time will not be before this
date.
所以你设置的实际上是计划作业的延迟,而不是解雇作业的延迟。这实际上并没有改变第一次执行的触发时间。
我正在使用 Grails 2.4.5 和 plugin quartz 1.0.2。我的工作:
class NotWellpaidJob {
def staticaService
static triggers = {
cron name: 'cronTrigger',startDelay:3000, cronExpression: "0/20 58 16 ? * MON-FRI"
}
def execute() {
print new Date()
}
}
我的输出:
Thu Nov 19 16:58:00 CET 2015
Thu Nov 19 16:58:20 CET 2015
Thu Nov 19 16:58:40 CET 2015
问题:
为什么 startDelay 不会将第一次执行延迟 3 秒并且第一个日期时间不是 Thu Nov 19 16:58:03 CET 2015?
当您在 cron 触发器上设置 startDelay
时,插件实质上是在修改在 Quartz 中 CronTriggerImpl class 上传递给 setStartTime
的内容。
从Quartz documentation起,开始时间定义为:
The time at which the trigger's scheduling should start. May or may not be the first actual fire time of the trigger, depending upon the type of trigger and the settings of the other properties of the trigger. However the first actual first time will not be before this date.
所以你设置的实际上是计划作业的延迟,而不是解雇作业的延迟。这实际上并没有改变第一次执行的触发时间。