问题
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