Scheduled with fixed delay in quartz scheduler?

浪子不回头ぞ 提交于 2019-12-08 07:26:23

问题


I have developed a job which I want to run say after every 5 mins, but there may be certain circumstances where the job completion time may exceeds 5 mins.

I am using quartz scheduler to schedule my job using a cron expression. Is there any way to tell quartz scheduler to hold the next run of job untill first one is completed?

I am looking for something similar to -

private static final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
executor.scheduledWithFixedDelay(..);

回答1:


Use a StatefulJob. From the docs:

stateful jobs are not allowed to execute concurrently, which means new triggers that occur before the completion of the execute(xx) method will be delayed.




回答2:


http://yongjun-jiao.blogspot.com/2010/08/quartz-crontrigger-scdeuling-policy.html. If you use spring scheduling concepts http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/dynamic-language.html



来源:https://stackoverflow.com/questions/5063482/scheduled-with-fixed-delay-in-quartz-scheduler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!