Hi Since you use ActiveMQ then when you use transacted, then you let ActiveMQ handle redelivery according to its redelivery policy settings. And those are 6 times and if still fail move message to the DLQ http://activemq.apache.org/redelivery-policy.html
So that could explain why you see that behavior. You can configure AMQ to your needs in terms of redelivery. And where to move the message if exhausted. On Wed, Feb 16, 2011 at 1:58 PM, Tom Howe <[email protected]> wrote: > Hi, I'm new to Camel and I am trying to create a simple app that consumes > messages from an ActiveMQ queue and forwards them to a TCP port (splunk). If > the TCP connection is down I want the message left on the queue and retried > with expontential backoff. > > I've been trying to understand the TransactionClient page but I find that > whatever I try, if I raise an exception or I give it an invalid destination, > camel retries to send 5 times and then then gives up and removes the message > from the queue. > > I have a simple app that creates a SpringCamelContext as follows: > > ApplicationContext applicationContext = new > ClassPathXmlApplicationContext("appContext.xml"); > > SpringCamelContext context = new > SpringCamelContext(applicationContext); > > and adds a Route: > > context.addRoutes(new MyRoute()); > context.start(); > > > The route looks like this.. > > class MyRoute extends SpringRouteBuilder { > > @Override > public void configure() throws Exception { > // errorHandler(deadLetterChannel("activemq:error")); > > SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", > SpringTransactionPolicy.class); > > errorHandler( > transactionErrorHandler(required) > .backOffMultiplier(5) > .maximumRedeliveries(100) > .useExponentialBackOff() > ); > > from("activemq-tom:queue:ispy?transacted=true") > .transacted("PROPAGATION_REQUIRED") > .policy(required) > .process(new Processor() { > > @Override > public void process(Exchange exchange) throws Exception > { > Message in = exchange.getIn(); > log.info("Message in: " + in); > throw new Exception("blah"); > } > }) > .to("mina:tcp://localhost:9999"); > } > } > > > My spring context contains: > > > <bean id="activemq-tom" > class="org.apache.activemq.camel.component.ActiveMQComponent"> > <property name="transacted" value="true"/> > <property name="configuration" ref="myConfigDelivery"/> > </bean> > > > <bean id="myConfigDelivery" > class="org.apache.camel.component.jms.JmsConfiguration"> > <property name="connectionFactory" > ref="jmsCachingConnectionFactoryDelivery"/> > <property name="transactionManager" > ref="jmsTransactionManagerDelivery"/> > <property name="concurrentConsumers" value="1"/> > <property name="maxConcurrentConsumers" value="1"/> > <property name="transacted" value="true"/> > </bean> > > <bean id="jmsTransactionManagerDelivery" > class="org.springframework.jms.connection.JmsTransactionManager"> > <property name="connectionFactory" > ref="jmsCachingConnectionFactoryDelivery"/> > </bean> > > > <bean id="jmsCachingConnectionFactoryDelivery" > class="org.springframework.jms.connection.SingleConnectionFactory"> > <property name="targetConnectionFactory" > ref="jmsConnectionFactoryDelivery"/> > </bean> > > <bean id="jmsConnectionFactoryDelivery" > class="org.apache.activemq.ActiveMQConnectionFactory"> > <property name="brokerURL" value="tcp://localhost:61616"/> > <!--<property name="redeliveryPolicy" > ref="redeliveryPolicyDelivery"/>--> > </bean> > > <bean id="redeliveryPolicyDelivery" > class="org.apache.activemq.RedeliveryPolicy"> > <property name="maximumRedeliveries" value="100"/> > <property name="useExponentialBackOff" value="true"/> > <property name="backOffMultiplier" value="10"/> > <property name="initialRedeliveryDelay" value="10000"/> > </bean> > > <!-- policy for required transaction used in our Camel routes --> > <bean id="PROPAGATION_REQUIRED" > class="org.apache.camel.spring.spi.SpringTransactionPolicy"> > <property name="transactionManager" > ref="jmsTransactionManagerDelivery"/> > <property name="propagationBehaviorName" > value="PROPAGATION_REQUIRED"/> > </bean> > > > I'm using the following dependencies: > > <dependency> > <groupId>org.springframework</groupId> > <artifactId>spring-core</artifactId> > <version>${org.springframework.version}</version> > <exclusions> > <exclusion> > <groupId>commons-logging</groupId> > <artifactId>commons-logging</artifactId> > </exclusion> > </exclusions> > </dependency> > > <dependency> > <groupId>org.springframework</groupId> > <artifactId>spring-context</artifactId> > <version>${org.springframework.version}</version> > </dependency> > > <dependency> > <groupId>org.springframework</groupId> > <artifactId>spring-context-support</artifactId> > <version>${org.springframework.version}</version> > </dependency> > > <dependency> > <groupId>org.springframework</groupId> > <artifactId>spring-tx</artifactId> > <version>${org.springframework.version}</version> > </dependency> > > <dependency> > <groupId>commons-lang</groupId> > <artifactId>commons-lang</artifactId> > <version>2.5</version> > </dependency> > > <dependency> > <groupId>org.apache.camel</groupId> > <artifactId>camel-spring</artifactId> > <version>2.5.0</version> > </dependency> > > <dependency> > <groupId>org.apache.camel</groupId> > <artifactId>camel-core</artifactId> > <version>2.5.0</version> > </dependency> > > > <dependency> > <groupId>org.apache.camel</groupId> > <artifactId>camel-jms</artifactId> > <version>2.5.0</version> > </dependency> > > <dependency> > <groupId>org.apache.camel</groupId> > <artifactId>camel-http</artifactId> > <version>2.5.0</version> > </dependency> > > <dependency> > <groupId>org.apache.camel</groupId> > <artifactId>camel-restlet</artifactId> > <version>2.5.0</version> > </dependency> > > <dependency> > <groupId>org.apache.camel</groupId> > <artifactId>camel-mina</artifactId> > <version>2.5.0</version> > </dependency> > > > <dependency> > <groupId>org.apache.activemq</groupId> > <artifactId>activemq-core</artifactId> > <version>5.2.0</version> > </dependency> > > <dependency> > <groupId>org.apache.activemq</groupId> > <artifactId>activemq-camel</artifactId> > <version>5.2.0</version> > </dependency> > > > Any help appreciated. > > Many thanks, Tom > -- Claus Ibsen ----------------- FuseSource Email: [email protected] Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
