camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Camel Transaction and errorHandlerRef question
Date Fri, 03 Jul 2009 08:07:04 GMT
On Fri, Jul 3, 2009 at 9:50 AM, Charles Moulliard<cmoulliard@gmail.com> wrote:
> Hi,
>
> 1) Best place of  TransactionErrorHandlerBuilder
>
> I would like to know where is the bast place to put the reference of the
> TransactionErrorHandlerBuilder in a transactional route ? At the level of
> the route OR transacted ?
>
>    <bean id="PROPAGATION_REQUIRED"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>        <property name="transactionManager">
>            <osgi:reference
> interface="org.springframework.transaction.PlatformTransactionManager"/>
>        </property>
>    </bean>
>
>    <bean id="txErrorHandler"
> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>        <property name="springTransactionPolicy"
> ref="PROPAGATION_REQUIRED"/>
>    </bean>
>
>    <camel:route errorHandlerRef="txErrorHandler"> // Here
>            <camel:from ref="queueQuickFixInEndpoint" />
>            <camel:convertBodyTo type="quickfix.Message" />
>            <camel:transacted ref="PROPAGATION_REQUIRED"/> // OR HERE
>            <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
>

Using <transacted> allows you to do convention over configuration. As
it can auto discover the spring TX manager itself.
That allows you to reduce the configuration to a bare minimum.

You *always* need to declare a route as transacted by setting the
   <transacted/>
otherwise the route is not transacted from a Camel point of view as it
uses this to weave in a TX interceptor.

It also makes reading the route easier as you can see its transacted.
And it should be the first step in the route.

So this is fine
    <camel:route errorHandlerRef="txErrorHandler">
            <camel:from ref="queueQuickFixInEndpoint" />
            <camel:transacted ref="PROPAGATION_REQUIRED"/>
            <camel:convertBodyTo type="quickfix.Message" />
            <camel:bean ref="serviceHelper" method="createNotification" />
            <camel:bean ref="serviceHelper" method="generateError" />
            <camel:to ref="directNotificationEndpoint" />
        </camel:route>

But <transacted> can also auto discover the error handler itself so
you can loose the errorHandlerRef if you want. But if you have
multiple error handlers then Camel does not know which to pick. So
what you do is good.






-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message