Hi,

Thanks for answering my question~

However, I did exactly what
http://activemq.apache.org/camel/transactional-client.html said and found
that neither the delay nor the maximumRedeliveries worked (the message is
redeliveried 7 times whatever maximumRedeliveries is). So I tried to change
the xml configuration to java DSL. But I didn't find how to use
transactionErrorHandler in DSL. Could you give me an example?

And I noticed that CAMEL-706 said delay not working in **all** conditions,
while you are saying "delay is **some** situations are not working". Is
there any hope that I can make the delay working in Camel 1.4 or I have to
wait for the next release? Thank you.


Claus Ibsen wrote:
> 
> Hi
> 
> No DeadLetterChannel is supposed to only be used for *non* transactional
> routes.
> 
> You should use the transactionErrorHandler instead = new feature in Camel
> 1.4.0. 
> In Camel 1.4.0, the DeadLetterChannel is skipped if the routing is in
> transacted mode. You can see this as it will log this at DEBUG level:
> "This is a transacted exchange, bypassing this DeadLetterChannel..."
> 
> See:
> http://activemq.apache.org/camel/transactional-client.html
> for samples, options etc.
> 
> You should be able to set the redelivery delay on the
> transactionErrorHandler also. Notice that it should actually be the the
> backing systems TransactionManager where you should set number of
> redeliveries, redelivery delay etc. if it's supported.
> 
> Mind that we have an issue reported in JIRA: CAMEL-706 that the delay is
> some situations are not working.
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> -----Original Message-----
> From: Lin.Zhang [mailto:[EMAIL PROTECTED] 
> Sent: 9. september 2008 05:25
> To: camel-user@activemq.apache.org
> Subject: Can DeadLetterChannel be used in Transaction?
> 
> 
> I tried to use DeadLetterChannel to add some redelivery delay when some
> exception occured. The problem I have now is if transaction is not used,
> the
> dlc works fine. But if in a transaction, the dlc just seems not work. I
> use
> ActiveMQ as the datasource and spring for transaction support. Can
> somebody
> tell me whether DLC can work in transactions? Here are my source files,
> Thanks.
> 
> [[aplicationContext.xml]]
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans";
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>        xmlns:camel="http://activemq.apache.org/camel/schema/spring";
>        xmlns:amq="http://activemq.apache.org/schema/core";
>        xsi:schemaLocation="
>         http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>         http://activemq.apache.org/camel/schema/spring
> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
>         http://activemq.apache.org/schema/core
> http://activemq.apache.org/schema/core/activemq-core.xsd";>
> 
>       <camel:camelContext id="camel" />       
>       
>       <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" />
>       </bean>
>       
>       <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
>               <property name="configuration" ref="jmsConfig" />
>       </bean>
>       
>       <bean id="PROPAGATION_REQUIRED"
> class="org.springframework.transaction.support.TransactionTemplate">
>               <property name="transactionManager" ref="jmsTransactionManager" 
> />
>       </bean> 
>       
>       <bean id="PROPAGATION_NOT_SUPPORTED"
> class="org.springframework.transaction.support.TransactionTemplate">
>               <property name="transactionManager" 
> ref="jmsTransactionManager"/>
>               <property name="propagationBehaviorName"
> value="PROPAGATION_NOT_SUPPORTED"/>
>       </bean>
> 
>       <bean id="PROPAGATION_REQUIRES_NEW"
> class="org.springframework.transaction.support.TransactionTemplate">
>               <property name="transactionManager" 
> ref="jmsTransactionManager"/>
>               <property name="propagationBehaviorName"
> value="PROPAGATION_REQUIRES_NEW"/>
>       </bean> 
>               
>       <bean id="jmsTransactionManager"
> class="org.springframework.jms.connection.JmsTransactionManager">
>               <property name="connectionFactory" ref="jmsConnectionFactory" />
>       </bean>         
>       
>       <bean id="jmsConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker">
>               <property name="brokerURL" value="tcp://localhost:61616" />
>       </bean>
>       
>       <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean">
>               <property name="config" value="/activemq.xml" />
>       </bean>
> </beans>
> 
> [[Main.java]]
> package com.abc.actxii;
> 
> import org.apache.camel.CamelContext;
> import org.apache.camel.CamelTemplate;
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.spi.Policy;
> import org.apache.camel.spring.SpringCamelContext;
> import org.apache.camel.spring.SpringRouteBuilder;
> import org.apache.camel.spring.spi.SpringTransactionPolicy;
> import org.springframework.context.ApplicationContext;
> import org.springframework.context.support.ClassPathXmlApplicationContext;
> import org.springframework.transaction.support.TransactionTemplate;
> 
> public class Main {
> 
>       private static ApplicationContext springContext;
>       private static CamelContext camelContext;
>       private static CamelTemplate camelTemplate;
>       
>       public static void main(String[] args) throws Exception {
>               springContext = new
> ClassPathXmlApplicationContext("applicationContext.xml");
>               camelContext = getCamelContext(springContext);
>               
>               camelTemplate = getCamelTemplate(camelContext);
>               
>               camelContext.addRoutes(new SpringRouteBuilder() {
>                       @Override
>                       public void configure() throws Exception {
>                               Policy required = new
> SpringTransactionPolicy(bean(TransactionTemplate.class,
> "PROPAGATION_REQUIRED"));
>                                                                               
>                 
>                               from("activemq:com.abc.actxii.dest")
>                               
> .errorHandler(deadLetterChannel("file://failure").maximumRedeliveries(5).initialRedeliveryDelay(2500).maximumRedeliveryDelay(30000))
>                                       .policy(required)
>                                       .process(new Processor() {              
>                                               
>                                               public void process(Exchange 
> exchange) throws Exception {
>                                                       
> System.out.println("message = " +
> exchange.getIn().getBody().toString() + ", " + System.currentTimeMillis()
> );
>                                                       throw new 
> Exception("test");
>                                               }
>                                       }).to("file://success");
>                       }
>               });
>                               
>               camelTemplate.sendBody("activemq:com.stubhub.actxii.dest", 
> "Hello
> World");
>       }
> 
>       private static CamelTemplate getCamelTemplate(CamelContext camelContext)
> {
>               return new CamelTemplate(camelContext);
>       }
> 
>       private static SpringCamelContext getCamelContext(
>                       ApplicationContext springContext) {
>               return (SpringCamelContext)springContext.getBean("camel");
>       }
> 
> }
> 
> -- 
> View this message in context:
> http://www.nabble.com/Can-DeadLetterChannel-be-used-in-Transaction--tp19385266s22882p19385266.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Can-DeadLetterChannel-be-used-in-Transaction--tp19385266s22882p19386157.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to