Quartz:触发多个作业
在Quarts中,我可以使用单个触发器来调度多个作业,以便所有作业并行执行。最好的方法是什么?
例如,每小时并行执行作业 j1, j2, ..., jn。假设作业之间不存在依赖关系。
In Quarts, can I use a single trigger to schedule multiple jobs, so that all the jobs gets executed in parallel. What is the best way to do this.
Example, every hour execute Jobs j1, j2, ..., jn in parallel. Assuming that there is no dependency between the jobs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法将多个作业与同一触发器关联(一个给定作业可以有多个触发器,但反之则不然),但您可以设置多个相同的触发器,每个作业一个触发器。
为了让它们并行运行,您需要确保 Quartz 的线程池有足够的容量来执行此操作。请参阅此处了解线程池的配置选项。
You can't associate multiple jobs with the same trigger (a given job can have multiple triggers, but not vice versa), but you can set up multiple identical triggers, one for each job.
In order to get them running in parallel, you need to ensure that Quartz's thread pool has enough capacity to do so. See here for the config options for the thread pool.
您可以构建一个触发其他作业的触发器作业。通过使用 JobMap 属性使其可配置,并且您可以重用该类来触发任意一组作业(并且可能自己执行第一个作业)。
You can build a trigger job that triggers the other jobs. Make it configurable by using the JobMap properties, and you can reuse the class for triggering an arbitrary set of jobs (and maybe executing the first for yourself).
我最终制作了一个帮助函数 GetTrigger
I ended up making a help function GetTrigger