<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 叱咤紅人 閱讀(4243) 評論(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  回復  更多評論
      

    主站蜘蛛池模板: 在线观看亚洲av每日更新| 亚洲成a人片在线观看日本| 免费精品国自产拍在线播放| 国产亚洲精品激情都市| 热re99久久6国产精品免费| 亚洲中文字幕日本无线码| 波多野结衣久久高清免费| 最近更新免费中文字幕大全 | 亚洲成a人片在线观看中文app| 免费无码不卡视频在线观看| 国产自国产自愉自愉免费24区 | 四虎www免费人成| 国产精品美女久久久免费| 激情综合亚洲色婷婷五月| 久久国产成人精品国产成人亚洲| 成人黄色免费网站| xvideos永久免费入口| 亚洲av产在线精品亚洲第一站| 最新精品亚洲成a人在线观看| 成人免费a级毛片无码网站入口 | 在线看片免费人成视频播| 亚洲男同gay片| 亚洲综合久久综合激情久久| 免费成人黄色大片| 国产在线观看片a免费观看| 成在人线av无码免费高潮喷水| 亚洲精品无码久久久久A片苍井空| 久久精品国产亚洲av麻| 免费女人18毛片a级毛片视频| 免费99精品国产自在现线| 成在人线av无码免费高潮喷水| 美女被免费视频网站| 亚洲综合久久一本伊伊区| 久久久久久亚洲精品| 亚洲国产成人久久综合一区77| 欧亚精品一区三区免费| 亚洲免费在线播放| a级片在线免费看| 一级一级一级毛片免费毛片| 蜜芽亚洲av无码一区二区三区| 激情亚洲一区国产精品|