Camel does not stop if I design the route like this (add a try/catch block
in the finally) :
<camel:route errorHandlerRef="txErrorHandler">
<camel:from ref="directRequestEndpoint" />
<camel:transacted ref="PROPAGATION_REQUIRED" />
<camel:doTry>
<!-- Call the requestService to save the request -->
<camel:bean ref="serviceHelper" method="createRequest" />
<!-- <camel:bean ref="serviceHelper" method="generateError"
/> -->
<camel:to ref="queueRequestEndpoint" />
<camel:doCatch>
<camel:exception>com.xpectis.x3s.exception.X3SException</camel:exception>
<camel:bean ref="serviceHelper"
method="processException" />
<camel:to ref="queueReportingEndpoint" />
</camel:doCatch>
</camel:doTry>
<camel:doFinally>
<camel:doTry>
<camel:bean ref="serviceHelper" method="generateError"
/>
</camel:doTry>
<camel:doCatch>
<camel:exception>com.xpectis.x3s.exception.X3SException</camel:exception>
<camel:to
uri="log:x3slog?level=DEBUG&multiline=true" />
<camel:rollback message="Exception occur" />
</camel:doCatch>
</camel:doFinally>
</camel:route>
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
On Mon, Jul 13, 2009 at 3:10 PM, Charles Moulliard <[email protected]>wrote:
> There is something strange. The rollbacks works but camel continues its
> route (see example here)
>
> <!-- Core component
> Flow IN to OUT
> Process P1
> -->
> <camel:route>
> <camel:from ref="fileClientEndpoint" />
>
> <camel:doTry>
> <camel:setHeader headerName="origin">
> <camel:constant>file</camel:constant>
> </camel:setHeader>
>
> <!-- Set Message type header with the name of the parent
> folder -->
> <camel:bean ref="serviceHelper"
> method="getParentFolderName"/>
>
> <camel:convertBodyTo type="java.lang.String"/>
> <camel:to ref="directRequestEndpoint" />
>
> <camel:doCatch>
> <camel:exception>java.lang.Exception</camel:exception>
> <camel:to
> uri="log:x3slog?level=DEBUG&multiline=true" />
> </camel:doCatch>
> </camel:doTry>
>
> </camel:route>
>
> <!-- Core component
> Flow IN to OUT
> Process P2
> -->
> <camel:route errorHandlerRef="txErrorHandler">
> <camel:from ref="directRequestEndpoint"/>
> <camel:transacted ref="PROPAGATION_REQUIRED"/>
> <camel:doTry>
> <!-- Call the requestService to save the request -->
> <camel:bean ref="serviceHelper"
> method="createRequest"/>
> <!-- <camel:bean ref="serviceHelper"
> method="generateError" /> -->
> <camel:to ref="queueRequestEndpoint" />
> <camel:doCatch>
>
> <camel:exception>com.xpectis.x3s.exception.X3SException</camel:exception>
> <camel:bean ref="serviceHelper"
> method="processException"/>
> <camel:to ref="queueReportingEndpoint" />
> </camel:doCatch>
> </camel:doTry>
> <camel:doFinally>
> <camel:bean ref="serviceHelper" method="generateError"
> />
> <camel:rollback message="Exception occur"/>
> </camel:doFinally>
> </camel:route>
>
> <!-- Core component
> Flow IN to OUT
> Process P3 technical parsing
> -->
> <camel:route>
> <camel:from ref="queueRequestEndpoint" />
> <camel:doTry>
>
> ...
>
> 1) Error is created in the finally
> 2) Rollback occurs on the service createRequest
> 3) Camel continues its route from message put in the queue :
> queueRequestEndpoint
>
> Question : Do we have to create a try/catch block in the doFinally ??
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Mon, Jul 13, 2009 at 2:56 PM, Claus Ibsen <[email protected]>wrote:
>
>> Hi
>>
>> doTry, doCatch, doFinally is meant to work 100% like try .. catch ..
>> finally in regular Java.
>>
>> So doFinally is called *always* no matter what.
>> And if you do a <rollback/> in doFinally then you will *always* do a
>> rollback :)
>>
>>
>> On Mon, Jul 13, 2009 at 2:49 PM, Charles Moulliard<[email protected]>
>> wrote:
>> > Hi,
>> >
>> > What will happen if an error occur in the finally block execution
>> defined
>> > here after ?
>> > Is the rollback put at the right place ?
>> >
>> > <route>
>> > <from uri="direct:start"/>
>> > <transacted/>
>> > <doTry>
>> > <process ref="processorFail"/>
>> > <to uri="mock:result"/>
>> > <doCatch>
>> > <!-- catch multiple exceptions -->
>> > <exception>java.io.IOException</exception>
>> > <exception>java.lang.IllegalStateException</exception>
>> > <to uri="mock:catch"/>
>> > </doCatch>
>> > <doFinally>
>> > <to uri="bean:finally"/> // The call to this bean generates
>> an error
>> > <rollback/> // Is it the right place of the rollback
>> ?????????
>> > </doFinally>
>> > </doTry>
>> > </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
>>
>
>