CXF supports resource local jms transactions and JTA transactions on CXF endpoints when using one way messages.
Resource local JMS transactions
This kind of transaction is easy to configure but will only roll back the JMS message. It will not directly coordinate other resources like a database transaction.
Simply configure the endpoint normally and set the propety "sessionTransacted" to true. CXF will then roll back the message on if any exception happens.
JTA transactions allow to coordinate any number of XA resources. If a CXF endpoint is configured for JTA transactions it will start a JTA transaction before calling the service impl. If no exceptions happen the transaction will be committed in case of any exception the transaction will be rolled back. This allows to e.g. transactionally consume a JMS message and write the data into a database. In case of an exception both resources will be rolled back. So either the message is consumed AND the database record is written or the message is rolled back AND the database record is not written.
The first config needed for JTA is a transaction manager:
Either create a transaction manager in a bean using:
<bean id ="transactionManager" class="org.apache.geronimo.transaction.manager.GeronimoTransactionManager"/>
as an OSGi service reference. (This search filter can vary between application servers).
<reference id="TransactionManager" interface="javax.transaction.TransactionManager"/>
Then the name of the TransactionManager can be set in the JMS URI
The first would find a bean with id "TransactionManager" the second would look up the transaction manager in JNDI.
The second config is a JCA pooling connection factory
<bean id="xacf" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616"/>
<bean id="ConnectionFactory" class="org.apache.activemq.jms.pool.JcaPooledConnectionFactory">
<property name="transactionManager" ref="transactionManager"/>
<property name="connectionFactory" ref="xacf"/>
This first defines an ActiveMQ XA connection factory. This is then given to a JcaPoolingConnectionFactory which is then provided as the default bean with id "ConnectionFactory".
It is important here that JcaPoolingConnectionFactory looks like a normal ConnectionFactory. When a new connection and session are opened it checks for an XA tranaction and automatically registers the JMS session as an XA resource. This allows the JMS session to participate in the JMS transaction. Do not directly set an XAConnectionFactory for the JMS transport. It would not work.