Tuesday, April 29, 2014

WLST script to set the XA Transaction timeout values for a data source in weblogic server

WLST script to set the XA Transaction timeout values for a data source in weblogic server


This tutorial explains the approach to set some of the important timeout properties for XA data sources in weblogic server through WLST script.

Set XA Transaction Timeout


Enables WebLogic Server to set a transaction branch timeout based on the value for XaTransactionTimeout.

When enabled, the WebLogic Server Transaction Manager calls XAResource.setTransactionTimeout() before calling XAResource.start, and passes either the XA Transaction Timeout value or the global transaction timeout.

XA Transaction Timeout


The number of seconds to set as the transaction branch timeout.
If set, this value is passed as the transaction timeout value in the XAResource.setTransactionTimeout() call on the XA resource manager, typically the JDBC driver.

When this value is set to 0, the WebLogic Server Transaction Manager passes the global WebLogic Server transaction timeout in seconds in the method.

If set, this value should be greater than or equal to the global WebLogic Server transaction timeout.


XA Retry Duration


Determines the duration in seconds for which the transaction manager will perform recover operations on the resource. A value of zero indicates that no retries will be performed.
XA Retry Interval

The number of seconds between XA retry operations if XARetryDurationSeconds is set to a positive value.

Please note the above configurations are only available to the data sources created with XA supported driver


WLST Script


The below wlst script set the required XA timeout properties

SetXATimeoutProperties.py
def setXATimeoutProperties():
   dsName='JDBC Data Source-0'
   edit()
   startEdit()
       
   server='AdminServer'
   cd("Servers/"+server)
   target=cmo
 
   print '========================================='
   print 'Setting the timeout properties for DataSource....'
   print '========================================='  
           
   cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCXAParams/'+dsName)
   cmo.setXaSetTransactionTimeout(true)cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCXAParams/'+dsName)
   cmo.setXaTransactionTimeout(3000)cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCXAParams/'+dsName)
   cmo.setXaRetryDurationSeconds(300)cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCXAParams/'+dsName)
   cmo.setXaRetryIntervalSeconds(60)save()
   activate()print 'Timeout settings for the datasource '+dsName+' has been completed'
 
 
def main():
     
    adminURL='t3://localhost:7001'
    adminUserName='weblogic'
    adminPassword='weblogic1'
    connect(adminUserName, adminPassword, adminURL)
    setXATimeoutProperties()
    disconnect()main()

Script

https://github.com/techforum-repo/youttubedata/blob/master/scripts/wlst/SetXATimeoutProperties.py

Before executing the script change the configuration values as required

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd SetXATimeoutProperties.py



Restart the server after successful execution. Now the XA configurations are enabled as required.



1 comment:

  1. what is XA Transaction Timeout? why it has to enable..? what's the relation between XA transaction and JDBC conn////if we enable XA tran...any help for tunning the server?

    ReplyDelete