Quartz支持在多个节点上执行一次吗? [英] Does Quartz support execute once on multiple node?

查看:156
本文介绍了Quartz支持在多个节点上执行一次吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的场景中,Quartz将嵌入在我的Web应用程序中运行,该Web应用程序将部署在两个节点上.我可以安排一个任务并使它在两个节点上仅执行一次吗?为此目的使用 DisallowConcurrentExecution 注释吗?

In my scenario, Quartz will run embedded within my web application which will be deployed on two nodes. Could I schedule a task and make it execute only once on the two nodes? Is DisallowConcurrentExecution annotation used for this purpose?

例如,如果我安排一个带有每小时触发器的任务,那么一天中两个节点上该任务的总执行计数是24个而不是48个吗?

For example, if I schedule a task with a per hour trigger, could the total execute count of the task in a day on the two node be 24 instead of 48?

推荐答案

您可以将quartz设置为集群模式.它的主要要求是服务的两个实例都应该共享与quartz基于石英的数据库相同的数据库.在数据库上.如果在这种情况下使用群集机制,则将执行24个作业.这些是您必须使用的一些属性.

You can set the quartz to be in clustered mode.The main requirement for it is both the instances of your service should share the same database as quartz does clustering based on database. If you use the clustering mechanism in your case 24 jobs will be executed.These are some of the properties that you have to use.

org.quartz.scheduler.instanceName = MyClusteredScheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval=20000

请参阅文档,网址为 http://www.quartz-scheduler.org/documentation/quartz-1.8.6/configuration/ConfigJDBCJobStoreClustering.html

这篇关于Quartz支持在多个节点上执行一次吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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