Question

I have a QUARTZ JOB which is starts every 10 minutes.

If a JOB doesn't finish in 10 minutes, in the next 10th minute another JOB will start.

What I want is: the next JOB (after every 10 minute) should start only, if the previous JOB has finished running. Is there any way to do it?

Was it helpful?

Solution

Quartz Documentation

@DisallowConcurrentExecution is an annotation that can be added to the Job class that tells Quartz not to execute multiple instances of a given job definition (that refers to the given job class) concurrently. Notice the wording there, as it was chosen very carefully. In the example from the previous section, if "SalesReportJob" has this annotation, than only one instance of "SalesReportForJoe" can execute at a given time, but it can execute concurrently with an instance of "SalesReportForMike". The constraint is based upon an instance definition (JobDetail), not on instances of the job class. However, it was decided (during the design of Quartz) to have the annotation carried on the class itself, because it does often make a difference to how the class is coded.

If you dont want SalesReportForMike and SalesReportForJoe to run concurrently ,then you can set the scheduler's ThreadPool size to 1. So at any given time only one job will run.

Also take a look at StatefulJob

OTHER TIPS

Take a look at the DisallowConcurrentExecution annotation which will prevent multiple instances of the same job to run at the same time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top