石英作业重叠

Quartz Jobs overlapping

我有几个 quartz (2.2) 作业 运行ning。假设一个是 运行ning 每 5 秒,另一个是 运行s 每 10 分钟。

我不想同时执行 2 个作业。我看过这个

DisallowConcurrentExecution

但这仅适用于来自同一实例的作业,但我通常不希望(任何实例的)两个作业重叠。

编辑: 所有作业都使用一个数据库,因此这就是为什么它们不要同时 运行 很重要的原因。每个工作都有不同的事情要做。

最简单的方法就是配置底层线程池使用一个线程,这样就可以达到你的目的。将以下 属性 添加到您的 quartz.properties 配置文件中:

org.quartz.threadPool.threadCount

The number of threads available for concurrent execution of jobs. You can specify any positive integer, although only numbers between 1 and 100 are practical. If you only have a few jobs that fire a few times a day, then one thread is plenty. If you have tens of thousands of jobs, with many firing every minute, then you want a thread count more like 50 or 100 (this highly depends on the nature of the work that your jobs perform, and your systems resources).