Integration Server 10.15 | JMS Client Development Guide | Sending and Receiving JMS Messages | Sending a JMS Message as Part of a Transaction
 
Sending a JMS Message as Part of a Transaction
 
How to Send a JMS Message within a Transaction
A transaction is a logical unit of work, composed of many different processes and involving one or more resources, that either entirely succeeds or has no effect at all. Transactions can either be implicit or explicit.
In an implicit transaction, the transaction manager in Integration Server automatically manages the transactions without requiring any additional services or input. In an explicit transaction, you control the transactional units of work by defining the start and completion boundaries of the transaction. The WmART package on Integration Server provides built-in services that you can use to start and complete transactions.
In some situations, you might use the built-in service pub.art.transaction:startTransaction to start a transaction explicitly, but then allow Integration Server to commit or roll back the transaction implicitly based on the success or failure of the service.
For more information about transactions see Transaction Management.
You can create a service that sends or receives JMS messages within an explicit transaction. The service must do the following:
*Use pub.art.transaction:startTransaction to start the transaction.
*Create a connection to the JMS provider using a JMS connection alias with a transaction type of LOCAL_TRANSACTION or XA_TRANSACTION, depending on the kind of transaction.
*Use pub.art.transaction:commitTransaction to commit the transaction.
*Use pub.art.transaction:rollbackTransaction to roll back the transaction.
Keep the following points in mind when building services that send or receive JMS messages within a transaction:
*To send or receive JMS messages within a transaction, you must install and enable the WmART package. (This is true even if you intend to use Integration Server to manage all transactions implicitly.)
*To use pub.jms:send or pub.jms:sendAndWait within a transaction, the client side queue cannot be used (the useCSQ parameter must be set to false).
*To use pub.jms:sendAndWait within a transaction, the request/reply must be asynchronous (the async parameter must be set to true). If async is set to false, Integration Server throws a JMSSubsystemException when the service executes.
*If you do not specifically invoke pub.art.transaction:commitTransaction or pub.art.transaction:rollbackTransaction, Integration Server implicitly commits the transaction when the services within the transaction are successful. Integration Server implicitly rolls back the transaction when one of the services within the transaction fails with any type of exception.