The same example works pretty fine using a Spring JPA TX manager with do try in camel. But I will try what you propose with JTA.
On Tue, Feb 8, 2011 at 3:11 PM, Christian Schneider <[email protected]> wrote: > Have you tried without the doTry and doCatch? > > I thought that the default behaviour would be to rollback in case of an > exception. > > Christian > > > Am 08.02.2011 14:58, schrieb Charles Moulliard: >> >> Hi, >> >> I have setup camel route with mode<transacted/> to perform rollback >> on Fuse ESB 4.3. Here is the route def. >> >> <bean id="activemq" >> class="org.apache.activemq.camel.component.ActiveMQComponent"> >> <property name="connectionFactory"> >> <osgi:reference interface="javax.jms.ConnectionFactory"/> >> </property> >> <property name="transacted" value="true" /> >> <property name="transactionManager"> >> <osgi:reference >> interface="org.springframework.transaction.PlatformTransactionManager"/> >> </property> >> </bean> >> >> <!-- SpringTransactionPolicy bean - PROPAGATION_REQUIRED_NEW inject >> OSGI reference --> >> <bean id="PROPAGATION_REQUIRED" >> class="org.apache.camel.spring.spi.SpringTransactionPolicy"> >> <property name="transactionManager"> >> <osgi:reference >> interface="org.springframework.transaction.PlatformTransactionManager"/> >> </property> >> <property name="propagationBehaviorName" >> value="PROPAGATION_REQUIRED"/> >> </bean> >> >> <route> >> <from uri="activemq:queue:in"/> >> <transacted/> >> <doTry> >> <bean ref="incidentSaver" method="process"/> >> <bean ref="generateError" method="generateError"/> >> <doCatch> >> <exception>java.lang.Exception</exception> >> <rollback/> >> </doCatch> >> </doTry> >> </route> >> >> Surprisingly, rollback does not occur and I get the following error : >> >> org.apache.camel.RuntimeCamelException: >> org.apache.camel.RollbackExchangeException: Intended rollback. >> Exchange[JmsMessage: ActiveMQObjectMessage {commandId = 6, >> responseRequired = false, messageId = >> ID:Charles-Moulliards-MacBook-Pro.local-57614-1297168327481-2:20:1:1:1, >> originalDestination = null, originalTransactionId = null, producerId = >> ID:Charles-Moulliards-MacBook-Pro.local-57614-1297168327481-2:20:1:1, >> destination = queue://in, transactionId = >> TX:ID:Charles-Moulliards-MacBook-Pro.local-57614-1297168327481-2:20:1, >> expiration = 0, timestamp = 1297173265400, arrival = 0, brokerInTime = >> 1297173265400, brokerOutTime = 1297173265408, correlationId = null, >> replyTo = null, persistent = true, type = null, priority = 4, groupID >> = null, groupSequence = 0, targetConsumerId = null, compressed = >> false, userID = null, content = >> org.apache.activemq.util.ByteSequence@3dcf5b66, marshalledProperties = >> org.apache.activemq.util.ByteSequence@7879a53d, dataStructure = null, >> redeliveryCounter = 0, size = 0, properties = >> {CamelFileNameOnly=incident.txt, CamelFileLastModified=Tue Feb 08 >> 14:54:25 CET 2011, CamelFileRelativePath=incident.txt, >> >> CamelFileAbsolutePath=/Users/charlesmoulliard/Applications/apache-servicemix-4.3.0-fuse-03-goodyear/data/reportincident/incident.txt, >> CamelFileLength=1099, CamelFileName=incident.txt, >> CamelFilePath=data/reportincident/incident.txt, >> CamelFileParent=data/reportincident, origin=file, >> CamelFileAbsolute=false}, readOnlyProperties = true, readOnlyBody = >> true, droppable = false}] >> at >> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1133)[72:org.apache.camel.camel-core:2.4.0.fuse-02-00] >> at >> org.apache.camel.spring.spi.TransactionErrorHandler$1.doInTransactionWithoutResult(TransactionErrorHandler.java:162)[79:org.apache.camel.camel-spring:2.4.0.fuse-02-00] >> at >> org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)[78:org.springframework.transaction:3.0.3.RELEASE] >> at >> org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)[78:org.springframework.transaction:3.0.3.RELEASE] >> >> >> Regards, >> >> Charles Moulliard >> >> Sr. Principal Solution Architect - FuseSource >> Apache Committer >> >> Blog : http://cmoulliard.blogspot.com >> Twitter : http://twitter.com/cmoulliard >> Linkedin : http://www.linkedin.com/in/charlesmoulliard >> Skype: cmoulliard >> > > -- > ---- > http://www.liquid-reality.de > >
