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

时光怂恿深爱的人放手 提交于 2019-12-05 11:51:19

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/22861365/how-to-set-to-a-quartz-job-to-start-only-when-an-another-job-finished-stopped

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!