camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From triswork <>
Subject JTA Transactions not rolling back in RouteBuilder
Date Sat, 09 May 2009 06:38:56 GMT


I am hoping someone can tell me what I am doing wrong here... I cannot get
transaction rollbacks to work in my Camel routes and I have tried everything
I can think of.

I have created a new component that consumes messages from a database table.
The messages are deleted, but a status flag is updated). These messages need
to be placed into a JMS queue. If an exception/fault occurs along the way,
the database updates must be rolled back and the JMS message must not be

The funny thing is that I can get JMS/JDBC rollbacks to work fine outside of
my routes - leading me to believe that I am doing something daft with my
custom component. The main difference is that I use the @Transactional
annotation outside my Route. Inside the route, I have tried to rely on
setting the SpringTransactionPolicy as per the examples in: 
My problem route looks like this:
Without any annotations in my component, the Spring debug output shows the
DEBUG - JtaTransactionManager      - Creating new transaction with name

I suspect that the [null] is a big part of the problem, but I can't find a
way to make is not null.

My component is extremely simple. I create a consumer that extends
The poll() method looks like this:

protected void poll() throws Exception {
    List<Map> queueItems = messageService.processQueue();
    for (Map q : queueItems) {
        Exchange exchange = endpoint.createExchange();

The processQueue() method returns batches of 20 queue items at a time (i.e.
20 exchanges are created every time poll() is called).

I am using Glassfish JPA for transaction management, ActiveMQ as a message
broker and the Spring SimpleJdbcTemplate for database access. T

My Spring config is fairly straight forward:

Transaction Manager
<bean id="transactionManager"
        <property name="transactionManagerName"
        <property name="allowCustomIsolationLevels" value="true"/>

<bean id="jmsConfig"
        <property name="connectionFactory" ref="activeMQConnectionFactory"/>
        <property name="transactionManager" ref="transactionManager"/>
        <property name="transacted" value="true"/>
        <property name="concurrentConsumers" value="1"/>

<bean id="activemq"
        <property name="configuration" ref="jmsConfig"/>

<jee:jndi-lookup id="activeMQConnectionFactory"
jndi-name="jms/ActiveMQConnectionFactory"/> (This is configured to use XA
transactions within Glassfish)

JDBC DataSource (JNDI Lookup From Glassfish) (This is configured to use XA
transactions within Glassfish)
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/MyDataSource"/> 

My Custom Component
<bean id="messageService" class="">
        <property name="dataSource" ref="dataSource"/>

<bean id="mmq" class="org.test.camel.component.mmq.MMQComponent">
        <property name="messageService" ref="messageService"/>
View this message in context:
Sent from the Camel - Users (activemq) mailing list archive at

View raw message