Using transactions with messaging
This recipe will show you how to set up transaction management over JMS for use within a Camel route, both for consuming and sending messages. This recipe will also detail the corner-case behaviors that you can expect from Camel when dealing with JMS transactions.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.transactions.jmstransaction
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with jmsTransaction
.
As discussed in the Introduction section, Camel's transaction handling relies on the Spring's PlatformTransactionManager
abstraction. Therefore, it is necessary to include the appropriate dependency in your application regardless of whether you are basing it on Spring or not—this includes regular Java as well as OSGi Blueprint applications.
To use Spring-managed JMS transactions you will require the following Maven dependencies:
<dependency> <groupId>org.apache.camel...