FAQ
My application is consuming a message from a ActiveMQ queue, after which it
does multiple operations in the database in the processor class. but if some
exception occurs while processing the message my database transaction does
not rollback, but the JMS transaction get roll back.

The same configuration is working in camel 1.6 but is not working in 2.6.
Can anyone suggest how the problem can be resolved.

Following is the sequence of steps

1 Start messaging transaction.
2 Receive message.
3 Start database transaction.
4 Update database.
5 Commit database transaction.
6 Commit messaging transaction.

Following is the configuration I am using

<---CAMEL CONFIGURATION -->

<camelContext id="myCamelContext" trace="true"
xmlns="http://camel.apache.org/schema/spring">

<route id="activeMqListenerRoute" errorHandlerRef="nullErrorHandler">
<from uri="activemq:messageQueue" />
<policy ref="jmsTransactionPolicy">
<to uri="direct:persistenseRoute" />
<to uri="activemq:resposneQueue" />
</policy>
</route>

<route id="persistenseRoute" errorHandlerRef="nullErrorHandler">
<from uri="direct:persistenseRoute" />
<policy ref="databaseTransactionPolicy">
<process ref="myProcessor" />
</policy>
</route>

</camelContext>



<bean id="redeliveryPolicy"
class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="-1" />
</bean>
<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL"
value="tcp://activeMqBroker:61615?jms.watchTopicAdvisories=false" />
<property name="redeliveryPolicy" ref="redeliveryPolicy" />
</bean>
<bean id="pooledJmsConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="pooledJmsConnectionFactory" />
</bean>
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="pooledJmsConnectionFactory" />
<property name="transacted" value="true" />
<property name="transactionManager" ref="jmsTransactionManager" />
</bean>

<bean id="jmsTransactionPolicy"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="propagationBehaviorName" value="PROPAGATION_REQUIRED" />
</bean>

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name="sessionFactory" ref="hibernateSessionFactory" />
</bean>

<bean id="PROPAGATION_REQUIRED"
class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="transactionManager" />
</bean>

<bean id="databaseTransactionPolicy"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<constructor-arg ref="PROPAGATION_REQUIRED" />
</bean>

<bean id="myProcessor" class="com.consumption.MyProcessor" />
<bean id="nullErrorHandler"
class="org.apache.camel.builder.NoErrorHandlerBuilder" />



--
View this message in context: http://camel.465427.n5.nabble.com/Database-trasaction-is-not-rolling-back-in-camel-2-6-tp5727118.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedFeb 7, '13 at 1:16p
activeFeb 7, '13 at 1:16p
posts1
users1
websitecamel.apache.org

1 user in discussion

Neeraj Mahajan: 1 post

People

Translate

site design / logo © 2022 Grokbase