zoukankan      html  css  js  c++  java
  • WebSphere 集群环境下配置 Quartz集群

    转载:http://hyamine.iteye.com/blog/397708

    1. websphere工作管理器引用

        WEB-INF/ibm-web-bnd.xmi

    Xml代码  收藏代码
    1. <?xml version="1.0" encoding="UTF-8"?>  
    2. <webappbnd:WebAppBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:webappbnd="webappbnd.xmi" xmi:id="WebAppBinding_1237946146690" virtualHostName="default_host">  
    3.   <webapp href="WEB-INF/web.xml#WebApp_1237946146690"/>  
    4.     <resRefBindings xmi:id="ResourceRefBinding_1238122581560" jndiName="wm/default">  
    5.       <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1238122581560"/>  
    6.   </resRefBindings>  
    7.  </webappbnd:WebAppBinding>  

       web.xml

    Xml代码  收藏代码
    1. <resource-ref id="ResourceRef_1238122581560">  
    2.       <res-ref-name>wm/default</res-ref-name>  
    3.       <res-type>commonj.work.WorkManager</res-type>  
    4.       <res-auth>Container</res-auth>  
    5.       <res-sharing-scope>Unshareable</res-sharing-scope>  
    6.    </resource-ref>  

     2. Spring配置

    注意: 

    1. dataSource请不要使用Spring注入
    2. job bean需要实现Serializable接口以序列化
    Xml代码  收藏代码
    1. <!-- 定义调度器 -->  
    2. <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">  
    3.     <property name="triggers">  
    4.         <list>  
    5.             <ref local="myStatefulJobBean"/>  
    6.         </list>  
    7.     </property>  
    8.     <!--注入事务管理器-->  
    9.     <property name="transactionManager" ref="transactionManager"/>  
    10.     <!-- 引用配置文件 -->  
    11.     <property name="configLocation" value="classpath:conf/quartz.properties"/>  
    12.     <!-- 应用WorkManager -->  
    13.     <property name="taskExecutor" ref="taskExecutor"></property>  
    14. </bean>  
    15. <!-- 定义事务引用 -->  
    16. <bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager"/>  
    17. <!--配置使用IBM commonj WorkManager-->  
    18. <bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">  
    19.     <property name="workManagerName" value="wm/default"/>  
    20.     <property name="resourceRef" value="false"/>  
    21. </bean>  
    22.   
    23. <!-- 声明有状态Job-->  
    24. <bean id="myStatefulJobBean" class="org.springframework.scheduling.quartz.JobDetailBean">  
    25.     <property name="jobClass" value="com.test.quartz.MyStatefulJobBean"/>  
    26. </bean>  
    27. <!-- 简单触发器 -->  
    28. <bean id="hibernateTestTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">  
    29.     <property name="jobDetail" ref="myStatefulJobBean"/>  
    30.     <property name="startDelay">  
    31.             <value>60000</value>  
    32.     </property>  
    33.         <property name="repeatInterval">  
    34.             <value>60000</value>  
    35.     </property>  
    36. </bean>  
    37.    

    job bean

    Java代码  收藏代码
    1. package com.test.quartz;  
    2.   
    3. import java.io.Serializable;  
    4.   
    5. import org.quartz.JobExecutionContext;  
    6. import org.quartz.JobExecutionException;  
    7. import org.quartz.SchedulerContext;  
    8. import org.quartz.SchedulerException;  
    9. import org.quartz.StatefulJob;  
    10.   
    11. import com.achievo.framework.workflow.HibernateSessionEnable;  
    12.   
    13. public class MyStatefulJobBean implements StatefulJob,Serializable{  
    14.       
    15.     @HibernateSessionEnable  
    16.     public void execute(JobExecutionContext context) throws JobExecutionException {  
    17.         String triggerName = context.getTrigger().getName();  
    18.         String jobName = context.getJobDetail().getName();  
    19.         System.out.println("触发器"+triggerName+"触发作业"+jobName);  
    20.     }  
    21.   
    22. }  

    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

  • 相关阅读:
    Compression algorithm (deflate)
    tcpip数据包编码解析(chunk and gzip)_space of Jialy_百度空间
    What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
    gzip压缩算法: gzip 所使用压缩算法的基本原理
    Decompressing a GZip Stream with Zlib
    Frequently Asked Questions about zlib
    how to decompress gzip stream with zlib
    自己动手写web服务器四(web服务器是如何通过压缩数据,web服务器的gzip模块的实现)
    What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
    C语言抓http gzip包并解压 失败 C/C++ ChinaUnix.net
  • 原文地址:https://www.cnblogs.com/chenying99/p/3189681.html
Copyright © 2011-2022 走看看