Integration Server 10.11 | JMS Client Development Guide | Sending and Receiving JMS Messages | Sending a JMS Message as Part of a Transaction | How to Send a JMS Message within a Transaction
 
How to Send a JMS Message within a Transaction
The following describes the general steps you take to send a JMS message to a JMS provider as part of a transaction (XA or Local).
1. Create an empty flow service.
2. Create the message body.
For more information about creating content for the body of a JMS message, see step 2 in the section How to Send a JMS Message.
3. Invoke pub.art.transaction:startTransaction.
This service starts an explicit transaction. This service is located in the WmART package.
In the startTransactionInput document list, you can provide the following optional parameter.
Name
Description
transactionName
A String that specifies the name of the transaction to be started. If this field is blank, Integration Server will generate a name for you.
If you do not use pub.art.transaction:startTransaction to start an explicit transaction, Integration Server starts an implicit transaction when it executes a pub.jms:send service that specifies a transacted JMS connection alias.
4. Invoke pub.jms:send.
This service takes the JMS message you created and sends it to the JMS provider.
5. Specify the JMS connection alias.
The JMS connection alias indicates how Integration Server connects to the JMS provider.
Name
Description
connectionAliasName
Name of the JMS connection alias that you want to use to send the message.
The specified JMS connection alias must have a transaction type of LOCAL_TRANSACTION or XA_TRANSACTION, depending on the kind of transaction.
6. Finish supplying inputs to the pub.jms:send service.
Follow steps 5-9 under How to Send a JMS Message.
7. Add any additional services to the transaction.
For example, you might want to invoke another built-in JMS service or an adapter service.
8. Insert logic to commit and/or rollback the transaction explicitly.
You may build your service to commit the transaction if all services execute successfully and to rollback the transaction if all services do not execute successfully.
*Invoke pub.art.transaction:commitTransaction to commit the transaction and send the JMS message. In the Pipeline view, map the contents of startTransactionOutput/transactionName to commitTransactionInput/transactionName.
*Invoke pub.art.transaction:rollbackTransaction to roll back the transaction. The message will not be sent to the JMS provider. In the Pipeline view, map the contents of startTransactionOutput/transactionName to rollbackTransactionInput/transactionName.
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.