quartz禁止一個工作任務還沒執行完,下一個工作(同jobkey)就開始執行的方法

在job接口實現類上添加@DisallowConcurrentExecution注解

@DisallowConcurrentExecution
public class IncrCrawlJob 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.

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容