第 32 章 配置 Quartz 计时器服务
当您在集群中运行 KIE Server 时,您可以配置 Quartz 计时器服务。
在应用服务器中配置数据库前,您必须准备 Quartz 的数据库,以创建 Quartz 表,该表将存放计时器数据和 Quartz 定义文件。
先决条件
- 支持的非JTA 数据源连接到应用服务器,如 PostgreSQL 数据源。
流程
在数据库中创建 Quartz 表,使计时器事件能够使用您的数据库的 DDL 脚本同步。
DDL 脚本位于
QUARTZ_HOME/docs/dbTables
中提取的 ZIP 存档中。注意包含单词
drop
的脚本,如quartz_tables_drop_db2.sql
在创建前丢弃 Quartz 表。在
JBOSS_HOME/MODE/configuration/
目录中创建 Quartz 配置文件quartz-definition.properties
,并添加以下示例内容:#========================================================================= # Configure Main Scheduler Properties #========================================================================= org.quartz.scheduler.instanceName = jBPMClusteredScheduler org.quartz.scheduler.instanceId = AUTO #========================================================================= # Configure ThreadPool #========================================================================= org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount = 5 org.quartz.threadPool.threadPriority = 5 #========================================================================= # Configure JobStore #========================================================================= org.quartz.jobStore.misfireThreshold = 60000 org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreCMT org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate org.quartz.jobStore.useProperties=false org.quartz.jobStore.dataSource=managedDS org.quartz.jobStore.nonManagedTXDataSource=notManagedDS org.quartz.jobStore.tablePrefix=QRTZ_ org.quartz.jobStore.isClustered=true org.quartz.jobStore.clusterCheckinInterval = 20000 #========================================================================= # Configure Datasources #========================================================================= org.quartz.dataSource.managedDS.jndiURL=jboss/datasources/psbpmsDS org.quartz.dataSource.notManagedDS.jndiURL=jboss/datasources/quartzNotManagedDS # Note the configured data sources that accommodate the two Quartz schemes at the very end of the file.
重要集群发现的建议间隔为 20 秒,在
quartz-definition.properties
文件的org.quartz.jobStore.clusterCheckinInterval
属性中设置。考虑对您的系统的性能影响,并根据需要修改设置。-
在
org.quartz.properties
属性中提供到quartz-definition.properties
文件的绝对路径。 可选: 要为 Quartz 触发器配置重试和延迟次数,请更新以下系统属性:
-
org.jbpm.timer.quartz.retries
(默认值为 5) -
org.jbpm.timer.quartz.delay
(默认值为 1000)
-
默认情况下,Qrtz 需要两个数据源:
- 参与进程引擎事务的受管数据源。
- 非受管数据源用来查找触发的计时器,而无需任何事务处理
Red Hat Process Automation Manager 新应用程序假定 Quartz 数据库(schema)将与 Red Hat Process Automation Manager 表共存,因此生成用于 Quartz 的事务操作的数据源。
必须配置其他(非事务)数据源,但应指向与主数据源相同的数据库。