石英:作业执行后可以自动关闭计划吗?



默认情况下,石英计划在作业执行后不会关闭。计划可以在作业执行后自动关闭吗?

是的,调度程序只有启动方法。但是,您可以控制重复计数,即调度程序应触发的次数。

检查下面的代码片段。

trigger = newTrigger()
.withIdentity("trigger3", "group1")
.startAt(myTimeToStartFiring)  // if a start time is not given (if this line were omitted), "now" is implied
.withSchedule(simpleSchedule()
.withIntervalInSeconds(10)
.withRepeatCount(10)) // note that 10 repeats will give a total of 11 firings
.forJob(myJob) // identify job with handle to its JobDetail itself                   
.build();

最新更新