spring quartz禁止一个工作任务还没执行完,下一个工作(同jobkey)就开始执行的方法

在job接口实现类上添加@DisallowConcurrentExecution注解

@DisallowConcurrentExecution
public class reyoJob implements Job {
 
    /** logger */

 

note:

    该时间段应该执行几个任务还是会执行几个任务,即使上一个任务执行完毕后已经超过该时间段

参考资料:

    @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.

 



posted @ 2022-02-19 12:18  锐洋智能  阅读(434)  评论(0编辑  收藏  举报