quartz-scheduler - quartz 调度器集群

标签 quartz-scheduler

我有一个 2 节点 HA 服务器。节点1为主用,节点2为备用。

我制作了一个应用程序并使用quartz api 进行集群。我已经在数据库中创建了所有表。

现在我需要在节点或 jst 节点 1 中运行该模块,以便当节点 1 出现故障时,应用程序会自动在节点 2 中启动。

在两个节点中运行模块时,触发器和作业名称应该相同还是不同?

quartz .属性:

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool

org.quartz.threadPool.threadCount = 10

org.quartz.threadPool.threadPriority = 5

org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true

-- 使用 RAMJobStore

-- 如果使用 RAMJobStore,请务必注释掉

-- org.quartz.jobStore.tablePrefix,org.quartz.jobStore.driverDelegateClass,org.quartz.jobStore.dataSource

-org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore

-- 使用 JobStoreTX

-- 确保首先运行适当的脚本(在 docs/dbTables 下)来创建数据库/表

org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX

-- 使用 DriverDelegate

org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate

--新的集群配置

org.quartz.jobStore.isClustered = true

org.quartz.jobStore.clusterCheckinInterval = 20000

org.quartz.scheduler.instanceId = AUTO

org.quartz.scheduler.instanceId = AUTO

org.quartz.scheduler.instanceName = MyClusteredScheduler

-- 使用表前缀配置 JDBCJobStore

org.quartz.jobStore.tablePrefix = QRTZ_

-- 使用数据源

org.quartz.jobStore.dataSource = qzDS

-- 定义要使用的数据源

org.quartz.dataSource.qzDS.driver = oracle.jdbc.driver.OracleDriver

org.quartz.dataSource.qzDS.URL = jdbc:oracle:thin:@10.172.16.147:1521:emadb0

org.quartz.dataSource.qzDS.user = BLuser

org.quartz.dataSource.qzDS.password = BLuser

org.quartz.dataSource.qzDS.maxConnections = 30

------------------------------------------------

最佳答案

根据: http://quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigJDBCJobStoreClustering

特别是:

Clustering currently only works with the JDBC-Jobstore (JobStoreTX or JobStoreCMT), and essentially works by having each node of the cluster share the same database.

Load-balancing occurs automatically, with each node of the cluster firing jobs as quickly as it can. When a trigger's firing time occurs, the first node to acquire it (by placing a lock on it) is the node that will fire it.

您应该启动所有节点,最快的节点会触发作业,其他节点会知道。

关于quartz-scheduler - quartz 调度器集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10983666/

相关文章:

java - Quartz 和 Spring Boot 的问题

java - 在系统时间为纽约时在伦敦时间安排任务

java - 定制@Scheduled Spring

c# - 长时间运行 WCF 504 GATEWAY_TIMEOUT 错误

c# - 使用集群的 Quartz.net 调度器

java - Quartz 2.0.2 - 安排重复事件

java - 如何制作一个持续时间为上午 11 点到凌晨 1 点的特定 cron 表达式?

java - Quartz Scheduler - 在作业之间仅更新 JobDataMap

java - Quartz 和 Spring 的 NullPointerException

java - 如何在指定次数后停止 quartz cron 调度程序?