<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    走自己的路

    路漫漫其修遠兮,吾將上下而求索

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      50 隨筆 :: 4 文章 :: 118 評論 :: 0 Trackbacks
    由于業務需要將quartz的jobstore從JobStoreTx更新為JobStoreCMT,接著啟動servlet時發現被鎖住了。由于使用jobstorecmt我們使用了managed datasource,按照quartz文檔的要求我也配置了non managed datasource,在quartz中什么是managed datasource和non managed datasource呢?

    Managed datasource: 使用了cmt才有的概念,應該主要是job執行時還有一些其他和job有關的操作quartz會用到的datasource,這個datasource是由容器來管理的,也就是一般意義上我們使用的managed datasource,但是它還強調的是transaction是由容器或者用戶自己的程序來控制(JTA)。quartz的job執行提供了一個UserTransaction的wrap。

    Non managed datasource; JobStoreTX默認就是使用這個datasource,默認是dbcp的pool,這個non managed datasource不是指我們不能使用容器管理的datasource,也可以配置成容器管理的datasource的,但要注意的是transaction level是local的,transaction是由quartz控制的,quartz來完成transaction的語義和邊界。


    一開始的配置如下:
    # The value of org.quartz.scheduler.instanceName
    # can be any string
    , and has no meaning to the scheduler itself -
    # but rather serves as a mechanism for client code to distinguish schedulers
    # when multiple instances are used within the same program.  If you are using
    # the clustering features
    , you must use the same name for every instance in 
    # the cluster that is 'logically' the same Scheduler.
    #
    # NOTE: Especially for the application using LTS
    , the instanceName is different and 
    #       specific per application to avoid the interruption between applications. For
    #       example in TMS project the instanceName could be named as TMS_APP
    , in DMS
    #       project the instanceName could be named as DMS_APP etc
    , the instanceName in
    #       different projects must be different. For more details
    , you could refer to
    #       the LTS installation guide.
    org.quartz.scheduler.instanceName 
    = LTS
    org.quartz.scheduler.rmi.export 
    = true
    org.quartz.scheduler.rmi.registryHost 
    = localhost
    org.quartz.scheduler.rmi.registryPort 
    = 1100
    org.quartz.scheduler.rmi.createRegistry 
    = as_needed
    org.quartz.scheduler.wrapJobExecutionInUserTransaction 
    = true


    org.quartz.threadPool.class 
    = org.quartz.simpl.SimpleThreadPool
    org.quartz.threadPool.threadCount 
    = 10
    org.quartz.threadPool.threadPriority 
    = 5
    org.quartz.jobStore.misfireThreshold 
    = 2592000000


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


    org.quartz.jobStore.driverDelegateClass 
    = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate

    org.quartz.jobStore.useProperties 
    = false
    org.quartz.jobStore.dataSource 
    = myXADS
    org.quartz.jobStore.nonManagedTXDataSource 
    = myDS
    org.quartz.jobStore.tablePrefix 
    = QRTZ_
    org.quartz.jobStore.isClustered 
    = false
    org.quartz.jobStore.selectWithLockSQL 
    = 

    org.quartz.dataSource.myXADS.jndiURL 
    = jdbc/ltstxxatest

    org.quartz.dataSource.myDS.driver 
    = oracle.jdbc.OracleDriver
    org.quartz.dataSource.myDS.URL 
    = jdbc:oracle:thin:@shhpdv11:1521:WOSDB
    org.quartz.dataSource.myDS.user 
    = sysint
    org.quartz.dataSource.myDS.password 
    = sysint
    org.quartz.dataSource.myDS.maxConnections 
    = 5






    datasource的配置:
        <managed-data-source name="LTSTxTestXADataSource"
            connection-pool-name
    ="LTSTxTestXAConnectionFactory"
            jndi-name
    ="jdbc/ltstxxatest" tx-level='global' />
        
    <!-- tx-level='global' -->
        
    <connection-pool name="LTSTxTestXAConnectionFactory">
            
    <connection-factory
                
    factory-class="oracle.jdbc.xa.client.OracleXADataSource"
                user
    ="sysint" password="sysint"
                url
    ="jdbc:oracle:thin:@shhpdv11:1521:WOSDB">
            
    </connection-factory>
        
    </connection-pool>

    但是發現servlet在啟動時hold在那里了,跟了一下代碼,發現quartz jobstoreCMT默認是使用的oracle db的TM鎖,而jobstoreTX使用的是java的邏輯鎖,于是登錄到db中,查了一下,發現一個insert quartz_simple_triggers的DML操作申請了Qaurtz_Locks的表鎖,而接著start quartz scheduler時也會去申請這個表鎖,但是前面的DML操作一直都沒有commit,所有quartz scheduler start時就被鎖在那里了。然后試著將non managed datasource和managed datasource配成同一個datasource啟動ok沒有問題,但是正是因為配了同一個datasource可能下一次從pool中拿的connection的oracle session還是擁有那個鎖資源的,鎖資源沒有被先前的connection釋放掉,因為事務沒有提交,connection的邏輯close不會釋放session擁有的資源。這樣又回到了原點,白試了一把,后來仔細跟了一把程序,發現autocommit是false,也沒有地方顯著的提交,scheduleJob和unscheduleJob都會有這種情況,本來以為只有job執行的時候會用到managed datasource,這樣看來很多對job信息的處理的地方都用到了managed datasource,但是為什么quartz不幫我們wrap起來提交呢,控制transaction的任務交給了我們自己或container,交給我們自己是指我們需要自己用JTA transaction封裝這些操作,交給container就需要把屬性:

    org.quartz.jobStore.dontSetAutoCommitFalse = true

    但是quartz文檔中提到下面這一段:

    org.quartz.jobStore.dontSetAutoCommitFalse

    False

    Description: Setting this parameter to true tells Quartz not to call setAutoCommit(false) on connections obtained from the DataSource(s). This can be helpful in a few situations, such as if you have a driver that complains if it is called when it is already off. This property defaults to false because most drivers require that setAutoCommit(false) be called.


    大概意思是大多數jdbc driver是不用去設置auto commit為true的,保持默認值是false就可以了,又看到了這篇文章:

    http://forums.opensymphony.com/thread.jspa?threadID=14762&messageID=28963#28963

    主要是說auto commit設成true會改變quartz transaction的語義,本來時多步操作提交的,現在變成了每步dml操作都會提交。但是如果不設auto commit在oracle jdbc中似乎沒辦法再提交這個transaction了,鎖就不會被釋放。于是找了找,找到了下面這篇文章:

    http://forums.opensymphony.com/thread.jspa?threadID=365430&messageID=452688#452688

    這篇文章也遇到了類似這樣的問題,提交了trigger但是沒有到db中,應該也是被鎖住了。提出的解決辦法就是把auto commit設成true。接著嘗試了一下,順利成功啟動,trigger成功調度,job成功執行。表面上看似沒有什么問題,但是一直還是有concern,因為我們這樣設置會不會更改了quartz事務的語義,仔細看了quartz jobstore相關的代碼,jobstorecmt中其實還有一個屬性:

        // Great name huh?
        protected boolean dontSetNonManagedTXConnectionAutoCommitFalse = false;

    文檔中的描述:

    org.quartz.jobStore.dontSetNonManagedTX ConnectionAutoCommitFalse

    False

    Description: This is the same as the property org.quartz.jobStore.dontSetAutoCommitFalse, except that it applies to the nonManagedTXDataSource.


    默認值是false,所有non managed datasource都是用的這個值,auto commit是false,設置org.quartz.jobStore.dontSetAutoCommitFalse = false不會影響non managed datasource的transaction語義。這樣想想把這個值設成true也不會有什么問題,不過進一步還是要進行大量的測試。所以oracle application server使用jobstorecmt后quartz的配置應該如下:

    # The value of org.quartz.scheduler.instanceName
    # can be any string
    , and has no meaning to the scheduler itself -
    # but rather serves as a mechanism for client code to distinguish schedulers
    # when multiple instances are used within the same program.  If you are using
    # the clustering features
    , you must use the same name for every instance in 
    # the cluster that is 'logically' the same Scheduler.
    #
    # NOTE: Especially for the application using LTS
    , the instanceName is different and 
    #       specific per application to avoid the interruption between applications. For
    #       example in TMS project the instanceName could be named as TMS_APP
    , in DMS
    #       project the instanceName could be named as DMS_APP etc
    , the instanceName in
    #       different projects must be different. For more details
    , you could refer to
    #       the LTS installation guide.
    org.quartz.scheduler.instanceName 
    = LTS
    org.quartz.scheduler.rmi.export 
    = true
    org.quartz.scheduler.rmi.registryHost 
    = localhost
    org.quartz.scheduler.rmi.registryPort 
    = 1101
    org.quartz.scheduler.rmi.createRegistry 
    = as_needed
    org.quartz.scheduler.wrapJobExecutionInUserTransaction 
    = true


    org.quartz.threadPool.class 
    = org.quartz.simpl.SimpleThreadPool
    org.quartz.threadPool.threadCount 
    = 10
    org.quartz.threadPool.threadPriority 
    = 5
    org.quartz.jobStore.misfireThreshold 
    = 2592000000


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


    org.quartz.jobStore.driverDelegateClass 
    = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate

    org.quartz.jobStore.useProperties 
    = false
    org.quartz.jobStore.dataSource 
    = myXADS
    org.quartz.jobStore.nonManagedTXDataSource 
    = myDS
    org.quartz.jobStore.tablePrefix 
    = QRTZ_
    org.quartz.jobStore.isClustered 
    = false
    org.quartz.jobStore.dontSetAutoCommitFalse 
    = true
    org.quartz.jobStore.selectWithLockSQL 
    = 

    org.quartz.dataSource.myXADS.jndiURL 
    = jdbc/ltstxxatest


    org.quartz.dataSource.myDS.driver 
    = oracle.jdbc.OracleDriver
    org.quartz.dataSource.myDS.URL 
    = jdbc:oracle:thin:@shhpdv11:1521:WOSDB
    org.quartz.dataSource.myDS.user 
    = sysint
    org.quartz.dataSource.myDS.password 
    = sysint
    org.quartz.dataSource.myDS.maxConnections 
    = 5




    posted on 2009-02-06 17:13 叱咤紅人 閱讀(4244) 評論(2)  編輯  收藏 所屬分類: Other Java and J2EE frameworks

    評論

    # re: Oracle application server使用Quartz JobStoreCMT遇到程序被鎖問題 2009-06-25 17:00 Tenny
    樓主:
     我因為項目需要也是將quartz的jobstore從JobStoreTx更新為JobStoreCMT,我在servlet啟動時沒錯,但是當我調度執行一個job時,在持久化存儲job的Blob信息時出錯:
    配置環境:weblogic9.22 + oracle 10g + quartz1.6
    org.quartz.JobPersistenceException: Couldn't store job: Driver's Blob representation is of an unsupported type: weblogic.jdbc.wrapper.Blob_oracle_sql_BLOB [See nested exception: java.sql.SQLException: Driver's Blob representation is of an unsupported type: weblogic.jdbc.wrapper.Blob_oracle_sql_BLOB]
    ....
    Caused by: java.sql.SQLException: Driver's Blob representation is of an unsupported type: weblogic.jdbc.wrapper.Blob_oracle_sql_BLOB
    ...
    我更新了oracle10g的最新jdbc驅動亦于事無補.我也不確信我的quartz配置是否正確,請幫我檢查一下:
    org.quartz.scheduler.instanceName = OnlineTaskQuartzScheduler
    #org.quartz.scheduler.rmi.export = true
    #org.quartz.scheduler.rmi.registryHost = localhost
    #org.quartz.scheduler.rmi.registryPort = 1101
    #org.quartz.scheduler.rmi.createRegistry = as_needed
    org.quartz.scheduler.wrapJobExecutionInUserTransaction = true

    org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
    org.quartz.threadPool.threadCount = 5
    org.quartz.threadPool.threadPriority = 5
    org.quartz.jobStore.misfireThreshold = 2592000000


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


    org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate

    org.quartz.jobStore.useProperties = false
    org.quartz.jobStore.dataSource = myXADS
    org.quartz.jobStore.nonManagedTXDataSource = myDS
    org.quartz.jobStore.tablePrefix = QRTZ_
    org.quartz.jobStore.isClustered = false
    org.quartz.jobStore.dontSetAutoCommitFalse = true
    org.quartz.jobStore.selectWithLockSQL =

    org.quartz.dataSource.myXADS.jndiURL = ReportDataSource
    org.quartz.dataSource.myXADS.jndiAlwaysLookup = DB_JNDI_ALWAYS_LOOKUP
    org.quartz.dataSource.myXADS.java.naming.factory.initial = weblogic.jndi.WLInitialContextFactory
    org.quartz.dataSource.myXADS.java.naming.provider.url = t3://localhost:7001
    org.quartz.dataSource.myXADS.java.naming.security.principal = weblogic
    org.quartz.dataSource.myXADS.java.naming.security.credentials = weblogic


    org.quartz.dataSource.myDS.driver = oracle.jdbc.OracleDriver
    org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@XXXXXXX:1521:dhcs
    org.quartz.dataSource.myDS.user = XXXXX
    org.quartz.dataSource.myDS.password = XXXXX
    org.quartz.dataSource.myDS.maxConnections = 5
    org.quartz.dataSource.myDS.validationQuery = select table_name from user_tables   回復  更多評論
      

    # re: Oracle application server使用Quartz JobStoreCMT遇到程序被鎖問題 2009-06-26 05:10 ldd600
    請使用 WebLogicDelegate  回復  更多評論
      

    主站蜘蛛池模板: 国产精品亚洲综合网站| 亚洲无限乱码一二三四区| 亚洲成a人无码亚洲成www牛牛| 免费成人激情视频| 亚洲国产精品网站久久| 国产h视频在线观看网站免费| 久久久无码精品亚洲日韩蜜臀浪潮 | rh男男车车的车车免费网站| 免费人妻av无码专区| 特级毛片爽www免费版| 国产亚洲精品福利在线无卡一| 中文字幕乱理片免费完整的| 亚洲爆乳精品无码一区二区三区 | 国产精品亚洲综合天堂夜夜| 亚洲欧洲日产国码一级毛片 | 国产精品无码免费专区午夜| 亚洲精品无码乱码成人| 在线看片免费人成视久网| 亚洲香蕉在线观看| 日韩在线免费看网站| 又长又大又粗又硬3p免费视频 | 国产片免费福利片永久| 色多多www视频在线观看免费| 亚洲中文字幕久久精品无码喷水| 免费一区二区三区| tom影院亚洲国产一区二区| 国产成人aaa在线视频免费观看 | 永久在线免费观看| 亚洲成a人片在线观看天堂无码 | 国产成人99久久亚洲综合精品| 永久免费不卡在线观看黄网站| 亚洲福利视频一区二区三区| 日韩高清免费在线观看| 国产精品青草视频免费播放| 亚洲冬月枫中文字幕在线看| 国产在线观看免费完整版中文版 | 日韩免费a级毛片无码a∨| 四虎影视在线看免费观看| 亚洲嫩草影院久久精品| 麻豆最新国产剧情AV原创免费| 日本一区二区三区在线视频观看免费|