如何设置QUARTZ JOB以仅在另一个JOB完成,停止后才开始? [英] How to set to a QUARTZ JOB to start only when an another JOB finished, stopped?

查看:208
本文介绍了如何设置QUARTZ JOB以仅在另一个JOB完成,停止后才开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个QUARTZ作业,该作业每10分钟启动一次.

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

如果一个作业在10分钟内未完成,则在接下来的10分钟内,另一个作业将开始.

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

我想要的是:下一个作业(每10分钟之后)应该仅在上一个作业已完成运行的情况下开始.有什么办法吗?

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?

推荐答案

石英文档

@DisallowConcurrentExecution是可以添加到 告诉Quartz不要执行的多个实例的作业类 给定的工作定义(指给定的工作类别) 同时.请注意那里的措辞,因为它的选择非常 小心.在上一节的示例中,如果 "SalesReportJob"具有此注释,而不是仅一个实例 "SalesReportForJoe"可以在给定时间执行,但是可以执行 与"SalesReportForMike"实例同时进行.约束 基于实例定义(JobDetail),而不基于 工作类别.但是,它是决定的(在Quartz设计期间) 使注释本身承载在类上,因为它确实 通常会改变类的编码方式.

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

如果您不希望SalesReportForMike和SalesReportForJoe同时运行,则可以将调度程序的ThreadPool大小设置为1.因此,在任何给定时间只能运行一个作业.

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.

还可以查看 StatefulJob

这篇关于如何设置QUARTZ JOB以仅在另一个JOB完成,停止后才开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆