Hi All,
I'm using Camel 1.6.1 (cannot use 2.0) , with Spring 2.5.6, and ActiveMQ 5.2.
I'm trying to set up Transaction Manager so that my transactions are
rolled back on error.
Here is my camel xml config adopted from the examples:
=========================================================================
<context:component-scan base-package="org.apache.camel.example.server"/>
<camel:camelContext id="camel">
<camel:package>org.apache.camel.example.server</camel:package>
<camel:jmxAgent id="agent" createConnector="true"/>
</camel:camelContext>
<broker:broker useJmx="false" persistent="false" brokerName="localhost">
<broker:transportConnectors>
<broker:transportConnector name="tcp" uri="tcp://localhost:61616"/>
</broker:transportConnectors>
</broker:broker>
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsConnectionFactory"/>
<property name="transacted" value="true"/>
<property name="transactionManager" ref="jmsTransactionManager"/>
<property name="transactionTimeout" value="50000"></property>
</bean>
<bean id="redeliveryPolicy"
class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="-1"/>
</bean>
<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<!-- use the vm protocol as the JMS broker is running in the
same
jvm as Camel -->
<property name="brokerURL" value="vm://localhost"/>
<property name="redeliveryPolicy" ref="redeliveryPolicy"/>
</bean>
<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="PROPAGATION_REQUIRED"
class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager"
ref="jmsTransactionManager"/>
</bean>
<bean id="transactionErrorHandler"
class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
<property name="transactionTemplate"
ref="PROPAGATION_REQUIRED"/>
</bean>
====================================================================
I have 2 routes.
Route 1 (extends from SpringRouteBuilder)
TransactionTemplate template =
bean(org.springframework.transaction.support.TransactionTemplate.class,
"PROPAGATION_REQUIRED");
Policy<TransactionTemplate> pp = new
SpringTransactionPolicy<TransactionTemplate>(template);
from("jms:queue:numbers")
.policy(pp)
.to("jms:queue:mybadqueue?transactedInOut=true")
.to("multiplier");
Route 2:
from("jms:queue:mybadqueue")
.process(new Processor() {
public void process(Exchange arg0) throws Exception {
throw new Exception("Hello World Exception");
}
})
.to("multiplier");
With this configuration I never get messages sent to "jms:queue:mybadqueue".
Could someone point me in the right direction? Please, advise.
Thank you.
Ilya.