camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lin.Zhang" <ygdra...@gmail.com>
Subject RE: Can DeadLetterChannel be used in Transaction?
Date Wed, 10 Sep 2008 03:57:53 GMT

I tested the maximumRedeliveries, it's the multiplication of the value of
ActiveMQ. That is, if set maximumRedeliveries of Camel to 5, and the
maximumRedeliveries of ActiveMQ is 5, then the message will be redelivered
25 times... not I wanted, but I can control it now. But I think the original
meaning should be a replacement of the underly systems.

 


Claus Ibsen wrote:
> 
> Hi
> 
> Keep an eye on CAMEL-706. Would be lovely if you would like to help test
> it in the 1.5-SNAPSHOT so we are sure it works in your environment before
> we make a final 1.5 release.
> 
> We have started to consider cutting a RC for 1.5 since we have 130+ issues
> fixed since 1.4.0. So I guess in 1-2 months 1.5 is released.
> 
> About maximumRedeliveries. Maybe ActiveMQ also has a default
> maximumRedeliveries that is kicked in before Camel. Remember that it's the
> backing system that is supposed to handle the redeliver policy. 
> 
> Have you tried with maximumRedeliveries=1 or maximumRedeliveries=0 for
> none at all. To see if Camel will move the message to the ERROR log?
> 
> 
> 
> 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:ygdrasil@gmail.com] 
> Sent: 9. september 2008 10:09
> To: camel-user@activemq.apache.org
> Subject: RE: Can DeadLetterChannel be used in Transaction?
> 
> 
> Thanks, really appreciate your help.
> 
> The trick works fine on the delay but the maximumRedeliveries doesn't.
> However, I can't use this in production until it's formal released. So I
> think I'll wait for the next release. Thank you the guys who make such a
> wonderful thing.
> 
> 
> 
> Claus Ibsen wrote:
>> 
>> Hi
>> 
>> You have to wait for the next release, where we plan to improve the
>> transaction error handler to fully support the RedliveryPolicy options,
>> as
>> far as we can.
>> 
>> However there is a trick that another end-user has used to use the
>> DeadLetterChannel but still in transacted mode.
>> 
>> You should not set all the spring PROPOGATION_REQUIRED and NOT use the
>> <policy>.
>> 
>> PROPOGATION_REQUIRED is default anyway, so then the DeadLetterChannel
>> will
>> still be active (policy not used) and you can control the number of
>> redeliveries, delay etc.
>> 
>> So you should just set the "transacted=true" on the ActiveMQ. However
>> notice that the message will still be rolled back on the ActiveMQ and
>> using its feature for redelivery handling. 
>> 
>> 
>> 
>> 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:ygdrasil@gmail.com] 
>> Sent: 9. september 2008 07:37
>> To: camel-user@activemq.apache.org
>> Subject: RE: Can DeadLetterChannel be used in Transaction?
>> 
>> 
>> 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:ygdrasil@gmail.com] 
>>> 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.
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Can-DeadLetterChannel-be-used-in-Transaction--tp19385266s22882p19387777.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--tp19385266s22882p19405897.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message