Quartz Scheduler execute job only if it is not already running [duplicate]

一曲冷凌霜 提交于 2019-12-12 03:43:44

问题


In my java web application I am using Quartz CronTrigger Bean to schedule the execution of a job. In my configuration xml file I want to trigger the job every 10 minutes:

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="processToExecuteJob" />
    <property name="cronExpression" value="0 0/10 * * * ?" />
</bean>

How can I check if the job is already running, and in tat case I do not need to run it again. I want to ensure that only one instance of the job can be running at certain time.


回答1:


I had a similar problem in an old project I worked on. I think an elegant solution in this case always the Singleton pattern

http://en.wikipedia.org/wiki/Singleton_pattern



来源:https://stackoverflow.com/questions/11843981/quartz-scheduler-execute-job-only-if-it-is-not-already-running

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