With this config in ActiveMq, it works and redelivery only one time the
message :

    <bean id="x3sPolicy" class="org.apache.activemq.RedeliveryPolicy">
        <property name="maximumRedeliveries" value="1"/>
    </bean>

    <bean id="activemqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61616" />
        <property name="redeliveryPolicy" ref="x3sPolicy"/>
    </bean>

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Fri, Jul 3, 2009 at 10:19 AM, Claus Ibsen <claus.ib...@gmail.com> wrote:

> On Fri, Jul 3, 2009 at 10:13 AM, Charles Moulliard<cmoulli...@gmail.com>
> wrote:
> > That was my idea to configure it like that after reading the
> documentation
> > but the following example make me wrong
>
> You can mix and match Camel redelivery and TX manager redelivery.
> The sample below will use Camel redelivery up till 4 times before
> Camel gives up and let the TX manager handle it.
>
> This allows to use redelivery at the point of failure as Camel can do
> redelivery where the error occured.
> For instance if a socket connection occured then Camel can retry again
> and go on if it works at 2nd attempt.
>
> Where as the TX manager have to rollback and start all over again.
>
> If you want TX manager only to handle redelivery then do not set any
> Camel redelivery policy at all.
> By default its disabled in Camel.
>
>
> And you must have transacted=true on your ActiveMQComponent
>    <property name="transacted" value="true"/>
>
>
>
> >
> > JMSTransactionErrorHandlerTest.xml
> >
> > <beans xmlns="http://www.springframework.org/schema/beans";
> >       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >       xmlns:camel="http://camel.apache.org/schema/spring";
> >       xsi:schemaLocation="
> >         http://www.springframework.org/schema/beans
> > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> >         http://camel.apache.org/schema/spring
> > http://camel.apache.org/schema/spring/camel-spring.xsd";>
> >
> >    <!-- START SNIPPET: e1 -->
> >    <!-- setup JMS connection factory -->
> >    <bean id="jmsConnectionFactory"
> > class="org.apache.activemq.ActiveMQConnectionFactory">
> >        <property name="brokerURL"
> > value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
> >    </bean>
> >
> >    <!-- setup spring jms TX manager -->
> >    <bean id="jmsTransactionManager"
> > class="org.springframework.jms.connection.JmsTransactionManager">
> >        <property name="connectionFactory" ref="jmsConnectionFactory"/>
> >    </bean>
> >
> >    <!-- define our activemq component -->
> >    <bean id="activemq"
> > class="org.apache.activemq.camel.component.ActiveMQComponent">
> >        <property name="connectionFactory" ref="jmsConnectionFactory"/>
> >        <!-- define the jms consumer/producer as transacted -->
> >        <property name="transacted" value="true"/>
> >        <!-- setup the transaction manager to use -->
> >        <!-- if not provided then Camel will automatic use a
> > JmsTransactionManager, however if you
> >             for instance use a JTA transaction manager then you must
> > configure it -->
> >        <property name="transactionManager" ref="jmsTransactionManager"/>
> >    </bean>
> >    <!-- END SNIPPET: e1 -->
> >
> >    <!-- START SNIPPET: e3 -->
> >    <!-- use a transaction error handler -->
> >    <bean id="myErrorHandler"
> > class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
> >        <property name="redeliveryPolicy" ref="myPolicy"/>
> >    </bean>
> >    <!-- and let it try to redeliver up till 4 times -->
> >    <bean id="myPolicy"
> class="org.apache.camel.processor.RedeliveryPolicy">
> >        <property name="maximumRedeliveries" value="4"/>
> >    </bean>
> >    <!-- END SNIPPET: e3 -->
> >
> >    <!-- START SNIPPET: e2 -->
> >    <camelContext xmlns="http://camel.apache.org/schema/spring";>
> >        <route errorHandlerRef="myErrorHandler">
> >            <!-- 1: from the jms queue -->
> >            <from uri="activemq:queue:okay"/>
> >            <!-- 2: mark this route as transacted -->
> >            <transacted/>
> >            <!-- 3: call our business logic that is myProcessor -->
> >            <process ref="myProcessor"/>
> >            <!-- 4: if success then send it to the mock -->
> >            <to uri="mock:result"/>
> >        </route>
> >    </camelContext>
> >
> >    <bean id="myProcessor"
> >
> class="org.apache.camel.component.jms.tx.JMSTransactionalClientTest$MyProcessor"/>
> >    <!-- END SNIPPET: e2 -->
> >
> >
> > </beans>
> >
> >
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Fri, Jul 3, 2009 at 10:01 AM, Claus Ibsen <claus.ib...@gmail.com>
> wrote:
> >
> >> On Fri, Jul 3, 2009 at 9:53 AM, Charles Moulliard<cmoulli...@gmail.com>
> >> wrote:
> >> > Hi,
> >> >
> >> > I have configured my route like this but Camel continues to redeliver
> 6
> >> > times the messages !!!
> >>
> >> Its the default redelivery by ActiveMQ you have to configure it how
> >> you want it to handle redelivery
> >> http://activemq.apache.org/redelivery-policy.html
> >>
> >> So its not Camel doing any redelivery, but the message does a rollback
> >> and then the TX manager will act according to the
> >> redelivery policy in ActiveMQ.
> >>
> >>
> >>
> >>
> >> >
> >> >    <bean id="myPolicy"
> >> class="org.apache.camel.processor.RedeliveryPolicy">
> >> > *        <property name="maximumRedeliveries" value="1"/>*
> >> >    </bean>
> >> >
> >> >    <bean id="txErrorHandler"
> >> > class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
> >> >        <property name="springTransactionPolicy"
> >> > ref="PROPAGATION_REQUIRED"/>
> >> >        <property name="redeliveryPolicy" ref="myPolicy"/>
> >> >    </bean>
> >> >
> >> >    <bean id="PROPAGATION_REQUIRED"
> >> > class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >> >        <property name="transactionManager">
> >> >            <osgi:reference
> >> >
> interface="org.springframework.transaction.PlatformTransactionManager"/>
> >> >        </property>
> >> >    </bean>
> >> >
> >> >        <camel:route errorHandlerRef="txErrorHandler">
> >> >            <camel:from ref="queueQuickFixInEndpoint" />
> >> >            <camel:convertBodyTo type="quickfix.Message" />
> >> >            <camel:transacted ref="PROPAGATION_REQUIRED"/>
> >> >            <camel:bean ref="serviceHelper" method="createNotification"
> />
> >> >            <camel:bean ref="serviceHelper" method="generateError" />
> >> >            <camel:to ref="directNotificationEndpoint" />
> >> >        </camel:route>
> >> >
> >> > Regards,
> >> >
> >> > Charles Moulliard
> >> > Senior Enterprise Architect
> >> > Apache Camel Committer
> >> >
> >> > *****************************
> >> > blog : http://cmoulliard.blogspot.com
> >> >
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> Apache Camel Committer
> >>
> >> Open Source Integration: http://fusesource.com
> >> Blog: http://davsclaus.blogspot.com/
> >> Twitter: http://twitter.com/davsclaus
> >>
> >
>
>
>
> --
> 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