You can play with the exceptions like this :
<camel:route errorHandlerRef="txErrorHandlerReqNew"> // Here is the
reference to the bean component who will handle the transaction exception
<camel:from ref="queueRequestMessageEndpoint" /> // activemq
queue endpoint
<camel:transacted ref="PROPAGATION_REQUIRED_NEW" /> // route as
transacted with NEW as transaction policy
<camel:doTry>
<camel:convertBodyTo type="java.util.List" />
<camel:split>
<!-- Iterate through the Request list -->
<camel:ognl>request.body</camel:ognl>
<camel:bean ref="serviceHelper"
method="transformRequestMessage" />
<camel:to ref="quickFixClientEndpoint" />
</camel:split>
<camel:doCatch> // Here we will handle client exception of
type X3SClientException
<camel:exception>com.xpectis.x3s.exception.X3SClientException</camel:exception>
<camel:bean ref="serviceHelper"
method="processException" />
<camel:to ref="queueReportingEndpoint" />
</camel:doCatch>
<camel:doCatch> // and here every technical exception
<camel:exception>java.lang.Exception</camel:exception>
<camel:to
uri="log:com.xpectis.x3s?level=INFO&multiline=true&showException=true&showCaughtException=true&showStackTrace=true"
/>
<camel:rollback/> // Route will be rollbacked in
this case
</camel:doCatch>
</camel:doTry>
</camel:route>
Regards,
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
On Tue, Aug 25, 2009 at 9:18 AM, trivedi kumar b
<[email protected]>wrote:
>
> Hi,
>
> This is working but with small issue, my bean (forex: y) is throwing an
> exception which is why the transaction is getting rollbacked. However, this
> exception is propagated to the client, instead I want to handle the
> exception. I have added onException() in my route, which didnt worked.
>
> Thanks,
> Trivedi
>
> Claus Ibsen-2 wrote:
> >
> > Hi
> >
> > If the from(x) is from a JMS queue then you should remember to add
> > transacted=true on the URI on it, eg
> >
> > from("activemq:queue:foo?transacted=true")
> > .policy(required)
> > .beanRef(y);
> >
> > As its a bit special for that one as it need to do some hooks into the
> > TX manager.
> >
> >
> > On Tue, Aug 25, 2009 at 7:42 AM, trivedi kumar
> > b<[email protected]> wrote:
> >>
> >> Hi,
> >>
> >> Thank you for the response on this. It helps me.
> >>
> >> Thanks,
> >> Trivedi
> >>
> >> trivedi kumar b wrote:
> >>>
> >>>
> >>> Hi All,
> >>>
> >>> I am new to this concept called using transactions inside my router. I
> >>> did
> >>> some googling on this, got some examples on jms Transaction Client. I
> am
> >>> trying to use transactions in my router. Here is my requirement:
> >>>
> >>> In my router, I want to start a transaction (new one) before I proceed
> >>> with next processor in the router. The next processor basically makes a
> >>> call to a bean, which would either throw an error or successful
> message.
> >>> If it is exception, I want to rollback the transaction.
> >>>
> >>> Can someone help me on this?
> >>>
> >>> thanks in advance,
> >>> Trivedi
> >>>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/using-Transactions-in-the-camel-router-tp25120513p25128696.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> >
> > --
> > Claus Ibsen
> > Apache Camel Committer
> >
> > Open Source Integration: http://fusesource.com
> > Blog: http://davsclaus.blogspot.com/
> > Twitter: http://twitter.com/davsclaus
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/using-Transactions-in-the-camel-router-tp25120513p25129569.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>