Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set to a QUARTZ JOB to start only when an another JOB finished, stopped?

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?

like image 308
victorio Avatar asked Apr 04 '14 11:04

victorio


People also ask

How do you run Quartz only once?

You can trigger job just once, like scheduler. TriggerJob. If you configure such job to be run on application start, of course it will run. It all depends on configuration.

How do you schedule multiple jobs using Quartz?

If you want to schedule multiple jobs in your console application you can simply call Scheduler. ScheduleJob (IScheduler) passing the job and the trigger you've previously created: IJobDetail firstJob = JobBuilder.

How do you start a stop Quartz scheduler?

deleteJob(jobKey(<JobKey>, <JobGroup>)); This method will only interrupt/stop the job uniquely identified by the Job Key and Group within the scheduler which may have many other jobs running. scheduler. shutdown();

How many jobs can Quartz handle?

The actual number of jobs that can be running at any moment in time is limited by the size of the thread pool. If there are five threads in the pool, no more than five jobs can run at a time.


1 Answers

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

like image 99
M.Faizal Avatar answered Oct 13 '22 21:10

M.Faizal