Quartz Scheduler execute job only if it is not already running

5.4k Views Asked by At

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

There are 1 best solutions below

0
On BEST ANSWER

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