WebSphere 集群环境下配置 Quartz集群
?
1. websphere工作管理器引用?? ?WEB-INF/ibm-web-bnd.xmi
?
?? web.xml
?
job bean
package com.test.quartz;import java.io.Serializable;import org.quartz.JobExecutionContext;import org.quartz.JobExecutionException;import org.quartz.SchedulerContext;import org.quartz.SchedulerException;import org.quartz.StatefulJob;import com.achievo.framework.workflow.HibernateSessionEnable;public class MyStatefulJobBean implements StatefulJob,Serializable{@HibernateSessionEnablepublic void execute(JobExecutionContext context) throws JobExecutionException {String triggerName = context.getTrigger().getName();String jobName = context.getJobDetail().getName();System.out.println("触发器"+triggerName+"触发作业"+jobName);}}?
?
3. 配置quartz相关信息?配置JobStoreCMT 需要两个数据源: 容器管理的数据源 和 JDBC连接数据源
conf/quartz.properties# Default Properties file for use by StdSchedulerFactory
# to create a Quartz Scheduler Instance, if a different
# properties file is not explicitly specified.
#
org.quartz.scheduler.instanceName = MyClusteredScheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.wrapJobExecutionInUserTransaction = false
#org.quartz.scheduler.userTransactionURL=jta/usertransaction
#org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.class = org.springframework.scheduling.quartz.LocalTaskExecutorThreadPool
#org.quartz.threadPool.threadCount = 10
#org.quartz.threadPool.threadPriority = 5
#org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
org.quartz.jobStore.misfireThreshold = 60000
#配置使用数据库存储调度信息 (JobStoreCMT 需要两个数据源)
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000
org.quartz.jobStore.dataSource = wasDataSource
org.quartz.jobStore.nonManagedTXDataSource = oracleDS
org.quartz.jobStore.tablePrefix = QRTZ_
#配置容器管理的数据源
org.quartz.dataSource.wasDataSource.jndiURL = java:comp/env/jdbc/oracleDataSource
#org.quartz.dataSource.wasDataSource.java.naming.factory.initial=
#org.quartz.dataSource.wasDataSource.java.naming.provider.url=
#org.quartz.dataSource.wasDataSource.java.naming.security.principal=
#org.quartz.dataSource.wasDataSource.java.naming.security.credentials=
#配置非容器管理的数据源(JDBC数据源)
org.quartz.dataSource.oracleDS.driver = oracle.jdbc.driver.OracleDriver
org.quartz.dataSource.oracleDS.URL = jdbc:oracle:thin:@10.244.150.20:1521:orcl
org.quartz.dataSource.oracleDS.user = oracleuser
org.quartz.dataSource.oracleDS.password = password
org.quartz.dataSource.oracleDS.maxConnections = 5
org.quartz.dataSource.oracleDS.validationQuery = select 0 from dual?
?4. 创建调度表在quartz下载目录docs/dbTables 目录下有针对各种数据库的sql script文件
本文使用oracle,所以登录oracle sqlplus 执行 @quartz下载目录/docs/dbTables/tables_oracle.sql