gpt4 book ai didi

java - 如何将 QUARTZ JOB 设置为仅在另一个 JOB 完成、停止时启动?

转载 作者:搜寻专家 更新时间:2023-10-30 20:00:42 29 4
gpt4 key购买 nike

我有一个每 10 分钟启动一次的 QUARTZ JOB。

如果一个 JOB 没有在 10 分钟内完成,则在接下来的第 10 分钟内另一个 JOB 将开始。

我想要的是:下一个 JOB(每 10 分钟后)应该仅在前一个 JOB 已完成运行时启动。有什么办法吗?

最佳答案

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.

如果您不希望 SalesReportForMike 和 SalesReportForJoe 同时运行,那么您可以将调度程序的线程池大小设置为 1。因此在任何给定时间都只会运行一个作业。

另请查看 StatefulJob

关于java - 如何将 QUARTZ JOB 设置为仅在另一个 JOB 完成、停止时启动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22861365/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com