Hi

Yeah TX and error handling is hard.

For background on error handling in Camel start from here:
http://camel.apache.org/error-handling-in-camel.html

Basically you cannot use TX with DeadLetterChannel.
All redelivery and whatnot is totally in the hands of the backing system.
So you should d configure the backing system how it should handle redelivery.

If you use AMQ then it has configuration to setup number of
redeliveries, delay intervals,
and the dead letter queue etc. There is a bit info here:
http://activemq.apache.org/redelivery-policy.html

BTW: Which version of Camel are you using?


On Mon, May 25, 2009 at 2:15 PM, Jörn Kottmann <kottm...@gmail.com> wrote:
> Hi everyone,
>
> my route receives messages from a durable activemq topic and writes these to
> a database.
> Now I tried to enhance the route with transactions, that worked so far, but
> I also want
> to configure the Transactional Error Handler to retry forever and not only
> six times.
>
> I configured transaction based on the documentation in camel-context.xml:
>
>   <bean id="jmsConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>       <property name="brokerURL"
>           value="tcp://xxxx" />
>   </bean>
>
>   <bean id="jmsTransactionManager"
>       class="org.springframework.jms.connection.JmsTransactionManager">
>       <property name="connectionFactory" ref="jmsConnectionFactory" />
>   </bean>
>
>   <bean id="jmsConfig"
> class="org.apache.camel.component.jms.JmsConfiguration">
>       <property name="connectionFactory" ref="jmsConnectionFactory" />
>       <property name="transactionManager" ref="jmsTransactionManager" />
>       <property name="transacted" value="true" />
>       <property name="concurrentConsumers" value="1" />
>   </bean>
>
>   <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>       <property name="configuration" ref="jmsConfig" />
>   </bean>
>
>   <bean id="PROPAGATION_REQUIRED"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>       <property name="transactionManager" ref="jmsTransactionManager" />
>       <property name="propagationBehaviorName"
> value="PROPAGATION_REQUIRED"/>
>   </bean>
>
> And I use the Java DSL to build my route:
>
>       getContext().addComponent("activemq", bean(ActiveMQComponent.class,
> "activemq"));
>       SpringTransactionPolicy required = bean(SpringTransactionPolicy.class,
>               "PROPAGATION_REQUIRED");
>
>       TransactionErrorHandlerBuilder builder =
> transactionErrorHandler(required);
>       RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
>       redeliveryPolicy.setMaximumRedeliveries(-1);
>       builder.setRedeliveryPolicy(redeliveryPolicy);
>             errorHandler(builder);
>
>
> from("activemq:topic:TransactionTest2?clientId=test2&durableSubscriptionName=test2")
>               .policy(required)
>               .process(new Processor(){
>                   @Override
>                   public void process(Exchange exchange) throws Exception {
>                       // After six times the message is dropped
>                       exchange.setException(new Exception("Test exception
> ..."));
>                   }})
>                .process(...);
>
> For me it looks like it still uses the Dead Letter Channel Error Handler and
> my call the errorHandler does not change the error handling.
Notice that AMQ might also have a default of 6 retries.


>
> Thanks for your help,
> Jörn
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to