You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "valerian.merkling" <va...@capgemini.com> on 2013/03/07 11:10:19 UTC

TransactionnalDeadLetterChannel ?

Hi, 

My route read a file, parse the xml stuff inside, valid and transform it to
finally write it somewhere else.

My goal is : on any unhandled error, rollback and redeliver up to X times,
every Y seconds and finally send the original file on another queue.

Right now, i've defined a deadLetterChannel, which does almost all the job,
except the message sent on the dead end queue is not the original file, but
the one just before the unhandled error.

I guess I've to deal with some transactionnal stuff, i've seen some example
about transaction on JMS endpoint, but nothings on file so i'm not sure
about the right way to follow...

Here is the code :

    <bean name="transform-xxx-yyy"
class="TEST.esb.transform.XXXtoYYYTransform" />
    <bean id="myDeadLetterErrorHandler"
class="org.apache.camel.builder.DeadLetterChannelBuilder">
        <property name="deadLetterUri" value="activemq:queue:toretry"/>
        <property name="redeliveryPolicy" ref="myRedeliveryPolicyConfig"/>
    </bean>
    <bean id="myRedeliveryPolicyConfig"
class="org.apache.camel.processor.RedeliveryPolicy">
        <property name="maximumRedeliveries" value="6"/>
        <property name="redeliveryDelay" value="10000"/>
    </bean>

    <camelContext id="central-cr-colisage"
xmlns="http://camel.apache.org/schema/spring" >
        <propertyPlaceholder id="properties"
location="file:D:/TEST/esb.properties" />
        <route id="xxx-to-yyy">
            <from uri="file://{{esb.colisage.root}}in//?delete=true" />
                <convertBodyTo type="java.lang.String"/>
                <to uri="validator:file:D://TEST//xsd//XXX.xsd"/>
                <to uri="file://{{esb.colisage.root}}save//" />
                <to uri="transform-xxx-yyy"/>
                <to uri="validator:file:D://TEST//xsd//YYY.xsd"/>
                <to uri="file://F:/{{esb.colisage.output.folder}}" />
        </route>
		<route id="error-to-retry-route">
            <from uri="activemq:queue:toretry"/>
            <log message="Parking ${in.headers.camelFileName}"
loggingLevel="ERROR"/>
            <to uri="file://{{esb.colisage.root}}retry//" />
        </route>
	</camelContext>


I don't know if i have to use the TransactionnalClient or if there's a way
to give a transactionnal aspect to the deadLetterChannel. Any help is
welcome !

Regards, 

Valerian



--
View this message in context: http://camel.465427.n5.nabble.com/TransactionnalDeadLetterChannel-tp5728729.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: TransactionnalDeadLetterChannel ?

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Mar 7, 2013 at 11:10 AM, valerian.merkling
<va...@capgemini.com> wrote:
> Hi,
>
> My route read a file, parse the xml stuff inside, valid and transform it to
> finally write it somewhere else.
>
> My goal is : on any unhandled error, rollback and redeliver up to X times,
> every Y seconds and finally send the original file on another queue.
>
> Right now, i've defined a deadLetterChannel, which does almost all the job,
> except the message sent on the dead end queue is not the original file, but
> the one just before the unhandled error.
>

There is an option to use the original message you should set to true.


> I guess I've to deal with some transactionnal stuff, i've seen some example
> about transaction on JMS endpoint, but nothings on file so i'm not sure
> about the right way to follow...
>
> Here is the code :
>
>     <bean name="transform-xxx-yyy"
> class="TEST.esb.transform.XXXtoYYYTransform" />
>     <bean id="myDeadLetterErrorHandler"
> class="org.apache.camel.builder.DeadLetterChannelBuilder">
>         <property name="deadLetterUri" value="activemq:queue:toretry"/>
>         <property name="redeliveryPolicy" ref="myRedeliveryPolicyConfig"/>
>     </bean>
>     <bean id="myRedeliveryPolicyConfig"
> class="org.apache.camel.processor.RedeliveryPolicy">
>         <property name="maximumRedeliveries" value="6"/>
>         <property name="redeliveryDelay" value="10000"/>
>     </bean>
>
>     <camelContext id="central-cr-colisage"
> xmlns="http://camel.apache.org/schema/spring" >
>         <propertyPlaceholder id="properties"
> location="file:D:/TEST/esb.properties" />
>         <route id="xxx-to-yyy">
>             <from uri="file://{{esb.colisage.root}}in//?delete=true" />
>                 <convertBodyTo type="java.lang.String"/>
>                 <to uri="validator:file:D://TEST//xsd//XXX.xsd"/>
>                 <to uri="file://{{esb.colisage.root}}save//" />
>                 <to uri="transform-xxx-yyy"/>
>                 <to uri="validator:file:D://TEST//xsd//YYY.xsd"/>
>                 <to uri="file://F:/{{esb.colisage.output.folder}}" />
>         </route>
>                 <route id="error-to-retry-route">
>             <from uri="activemq:queue:toretry"/>
>             <log message="Parking ${in.headers.camelFileName}"
> loggingLevel="ERROR"/>
>             <to uri="file://{{esb.colisage.root}}retry//" />
>         </route>
>         </camelContext>
>
>
> I don't know if i have to use the TransactionnalClient or if there's a way
> to give a transactionnal aspect to the deadLetterChannel. Any help is
> welcome !
>
> Regards,
>
> Valerian
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/TransactionnalDeadLetterChannel-tp5728729.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen