如何限制石英调度程序中特定类并发执行的作业实例数? [英] How to limit number of job instance of particular class concurrent execution in quartz scheduler?
问题描述
我有一个实现 Job 的Applier"类.表示类Applier"是 Quartz Job 的实例之一.
I have a class "Applier" which implement Job . Means class "Applier" is one of instance of Quartz Job.
我的要求是控制一次执行Applier"的实例数.意味着我想限制最多执行 5 个Applier"实例.如果第 6 个Applier"实例出现并且第 5 个实例已经在执行,则必须等到Applier"实例之一完成.
My requirement is to control number of instance of "Applier" execute at a time. Means i want to make limit like at a time maximum 5 instance of "Applier" execute. If 6th instance of "Applier" come and 5 instance already executing than it must have to wait until one of the instance of "Applier" completed.
Quartz Scheduler 中是否有任何等待/通知类型的机制.意味着如果 Job 的第 6 个实例尝试运行并且 5 个已经执行的实例比第 6 个实例必须等待并在 5 个实例中的任何一个执行完成后通知.
Is there any wait/notify type mechanism in Quartz Scheduler. Means if 6th instance of Job try to run and 5 instance of already executing than 6th instance must have to wait and notify after any of the 5 instance execution completed.
意味着我想为 Job 的特定实例实现一些 ThreadPool 类型的机制.我不想要 ThreadPool Like mechanisum 在 Quartz Scheduler 级别 b'coz 它已经由 Quartz Scheduler 提供.
Means i want to achive some ThreadPool type mechanism for particular instance of Job . I do not want ThreadPool Like mechanisum at Quartz Scheduler level b'coz it is already provided by the Quartz Scheduler.
推荐答案
您可以限制并发运行的作业数量(线程池),也可以将给定的作业实例限制为仅一个并发实例.您不能将给定作业限制为仅给定数量的实例(1 个除外).做你想做的唯一方法是只为给定的调度程序运行一种作业,然后将线程池限制为你想要在同一时间运行的作业数量
You can either limit the number of jobs that run concurrently (threadpool) or you can limit a given instance of job to only one concurrent instance. You can't limit a given job to only a given number of instances (other than 1). The only way to do what you want to do is to only run one kind of job for a given scheduler and then limit the threadpool to the number of jobs you want running at the same tieme
这篇关于如何限制石英调度程序中特定类并发执行的作业实例数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!