camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" ...@silverbullet.dk>
Subject RE: Can DeadLetterChannel be used in Transaction?
Date Tue, 09 Sep 2008 09:39:23 GMT
Hi

I am thinking about for starters just to support:
- delay settings for the transactionalErrorHandler

Then we can later find a suitable strategy for the max redeliver if its possible and a feature
we would like to have in Camel.

I will also create a sample with ActiveMQ to show how configure it to set the maximum redeliver
and its error queue as a sample for Camel. Many end-users use Camel + ActiveMQ so a good example
would be nice.



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: James Strachan [mailto:james.strachan@gmail.com] 
Sent: 9. september 2008 11:09
To: camel-user@activemq.apache.org
Subject: Re: Can DeadLetterChannel be used in Transaction?

For JMS, the underlying system should have a redelivery policy; so
having another one in Camel probably doesn't make a whole lot of sense
as it might end up confusing the end user. i.e. you'd get confused if
you set a high redelivery count in Camel but then the underlying JMS
provider used its own limit and sent it to its own DLQ bypassing
whatever DLQ configuration you'd created in Camel.

Though for database or EJB related transactions, having a
transactional DLQ policy sounds great - though the complex thing is
gonna be determining what transactions are actually being redelivered
- i.e. where to store the retry counter


2008/9/9 Claus Ibsen <ci@silverbullet.dk>
>
> 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.
>



--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Mime
View raw message