0

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.

Rami
  • 8,044
  • 18
  • 66
  • 108
  • 1
    Can't your job just check whether an instance already exists and exit if it does? – Vala Aug 07 '12 at 10:33
  • Yes it can... Thank you :) I thought that there is a solution offered by org.springframework.scheduling.quartz.CronTriggerBean it self. – Rami Aug 07 '12 at 10:35
  • No problem. Sometimes the simple solutions are the best. ;) – Vala Aug 07 '12 at 10:55
  • 4
    Probably, i didn't understand the question. But, there is @DisallowConcurrentExecution annotation in Quartz: _"An annotation that marks a Job class as one that must not have multiple instances executed concurrently (where instance is based-upon a JobDetail definition - or in other words based upon a JobKey)"_ – Popandopolos Jul 02 '13 at 10:26

1 Answers1

0

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

klebe85
  • 286
  • 2
  • 13