0
votes

I'm using Quartz together with Spring. The JobStore that I'm using is the RAMJobStore.

I create a couple of jobs with the same identification (they have the same instance definition (JobDetail)). Because I want to make sure that these jobs aren't executed in parallel, I annotated their job class with @DisallowConcurrentExecution.

My problem is that the RAMJobStore doesn't allow more than one job with the same identification in the same time in the store, so when I try to add the job I get the exception:

   org.quartz.ObjectAlreadyExistsException: Unable to store Job : 
   'jobX', because one already exists with this identification.

Do you have any idea about how I can overcome this problem?

Thanks a lot!

2

2 Answers

1
votes

If you have two different jobs that are running on two different triggers, then I'm not aware of any Quartz annotations that would prevent the two jobs from running in parallel. You could reference the Scheduler instance in each of the jobs to determine if the other job is executing. Then you could pause or reschedule jobs to prevent them from running in parallel.

0
votes

It is clear from the RAMJobStore source code that there can't be two jobs with the same key in the same time in the RAMJobStore.

Have a look here at the source code.