Show TOC

Using JMS XA TransactionsLocate this document in the navigation structure

Use

SAP JMS Provider supports distributed transactions and uses the two-phase commit transaction protocol. In particular, SAP JMS Provider implements the javax.transaction.xa.XAResource interface, the javax.jms.XAConnection , and the javax.jms.XASession interface following the X/Open Distributed Transaction Processing (DTP) model. This model specifies the relations between applications, Resource Managers, and the Transaction Manager in a common transaction.

More information: Two-Phase Commit

Distributed Transactions

When an application needs to request updates to several different databases and to insure the atomicity between tasks of different resource managers (such as the JMS Provider and a database) it uses distributed transactions. Such transactions have several states that correspond to the each phase of their life cycle: ACTIVE , IDLE , SUSPENDED , PREPARED , ROLLBACK_ONLY , HEUR_COMMITTED , HEUR_ROLLEDBACK .

More information about the distributed transactions and their states: Distributed Transactions

JMS XA Transactions

A JMS XA transaction is a transaction that uses JMS logic.

When a XA session is not part of a transaction, it behaves like an AUTO_ACKNOWLEDGE session, that is, it automatically acknowledges all messages received by the client. When a distributed transaction is started, the JMS session becomes part of this transaction together with all messages produced within this session.

To monitor the JMS XA transaction, you can use the jms_monitor xaTransactions [-vp=<virtualProviderName>] [-mode=runtime|db] [-full=<true|false>] Telnet command. It shows detailed information about the available transaction in the runtime structures and from the database of all available Virtual Providers. If you specify -mode=runtime , the information is displayed for all transactions of all available Virtual Providers and you do not need to specify the [-vp=<virtualProviderName>] option. If you specify -mode=db , the information is displayed for the given Virtual Provider. If you do not use the [-vp=<virtualProviderName>] option, the information is displayed for the default Virtual Provider.

The displayed information contains several columns:

  • The XID column indicates the ID of the transaction that is specified by the Transaction Manager.

  • The TXID column shows the mapping of the XID to the internal JMS transaction ID. The TXID number is unique for every JMS XA transaction and all JMS operations use it.

  • The State column indicates the state of the transaction.

    The following graphic shows the relations between these states. The transaction is put into INITIAL state as soon as the commit method is invoked on any XAResource .

  • The Expiration column shows the date and time until when the transaction is valid. If it is not committed or rolled back until that time, it is automatically committed or rolled back. According to the configuration the state is set to HEUR_COMMITTED or HEUR_ROLLEDBACK .

Note

Messages, which are part of a distributed transaction, are persisted after the transaction enters the PREPARED state, so they can survive a server outage.

There are three properties, which influence the JMS XA behavior:

  • XAActiveTimeout - defines the period in milliseconds between the ACTIVE to PREPARE states. If the time exceeds the specified value before the transaction enters the PREPARE state, the state is automatically set to ROLLBACK_ONLY . The default value is 1800000.

  • XAHeuristicBehavior - defines whether the state of the transaction after expiration is HEUR_COMMITTED or HEUR_ROLLEDBACK after the PREPARE state. The default value is rollback .

  • XAHeuristicTimeout - defines the period in milliseconds between the PREPARE to INITIAL states. By this time the transaction has to be committed or rolled back. If the time exceeds the specified value before the transaction enters the INITIAL state, it is automatically committed or rolled back. According to the configuration the state is set to HEUR_COMPLETED (either HEUR_COMMITTED in case of a commit, or HEUR_ROLLEDBACK in case of a rollback). The default value is 86400000.

Procedure

Specifying the Transaction-Related Properties Using SAP NetWeaver Administrator

You can change the values of the properties XAActiveTimeout , XAHeuristicBehaviour , and XAHeuristicTimeout using the SAP NetWeaver Administrator:

  1. Open the SAP NetWeaver Administrator and choose Start of the navigation path Configuration Next navigation step Infrastructure Next navigation step Java System Properties End of the navigation path.

  2. In the Templates section, select an appropriate template.

  3. In the Details section, choose Services tab and select the JMS Provider service.

  4. In the Extended Details section, select a property and choose Modify .

  5. Enter the new value in the Enter Custom Value field. This value is measured in milliseconds. Choose Set . The specified value appears in the Custom Calculated Value column.

  6. Choose Save .

For detailed information about a specific property, select the property and then choose Show Details .

If you want to turn back the value of a property to its default one, choose Restore to Default .

Specifying the Transaction-Related Properties Using Telnet

You can change the values of the properties XAActiveTimeout , XAHeuristicBehaviour , and XAHeuristicTimeout using telnet. Enter the following command in the telnet console:

               listsp jms_provider
            

To change the value of one of the properties, enter the respective command:

  •                      setsp -p XAActiveTimeout [new_value] jms_provider
                      
  •                      setsp -p XAHeuristicBehaviour [commit/rollback] jms_provider
                      
  •                      setsp -p XAHeuristicTimeout [new_value] jms_provider
                      

Monitoring JMS XA Transactions via Telnet

You can monitor the transaction using the telnet command jms_monitor xaTransactions [-vp=<virtualProviderName>] [-mode=runtime|db] [-full=<true|false>] where the additional parameters are:

  • [-vp=<virtualProviderName>] - specifies the name of the JMS virtual provider.

  • [-mode=runtime|db] - shows whether the distributed transactions are listed from the database or in runtime. By default are printed both - from the database and in runtime.

  • [-full=<true|false>] - if this parameter is set to true , it shows the full XID; if it is false , a short version of the XID is printed. By default the value is false .