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: Unexpected behaviour of TransactionErrorHandler?
Date Sat, 21 Nov 2009 06:14:24 GMT
On Fri, Nov 20, 2009 at 10:41 AM, Martin Krasser <dev@martin-krasser.de> wrote:
> ... not part of the Camel 2.0.0 Javadocs ...
>

Ah my bad. I missed your obvious statement about using 2.0.0. And the
new markRollbackOnly() was added in 2.1. And hence its of course not
mentioned in the javadoc.
Sorry for sounding rudy or anything. Just wanted a generic hint that
the DSL method do actually have javadoc which is a good way to check
as there are links to other methods.
Which should lead you to markRollbackOnly() <--> rollback().

And if those javadocs are unclear whats the difference or what they
do, then please help improve them. Having links to the Camel wiki site
for more info is also something we try to add.



> Claus Ibsen schrieb:
>>
>> On Fri, Nov 20, 2009 at 10:36 AM, Claus Ibsen <claus.ibsen@gmail.com>
>> wrote:
>>
>>>
>>> On Fri, Nov 20, 2009 at 10:35 AM, Martin Krasser <dev@martin-krasser.de>
>>> wrote:
>>>
>>>>
>>>> I know that when I don't declare the local exception handler a rollback
>>>> will
>>>> occur. But how can I handle the exception for returning a custom
>>>> response to
>>>> the sender AND rollback the transaction? Maybe I'm missing something
>>>> obvious
>>>> (?).
>>>>
>>>
>>> Use markRollbackOnly()
>>>
>>>
>>
>> In fact the DSL have javadoc you know so try looking there also :)
>>
>> But this use case will definitely also be in my book, as I currently
>> write on chapter 9 about transactions.
>>
>>
>>
>>>
>>>
>>>>
>>>> Claus Ibsen schrieb:
>>>>
>>>>>
>>>>> On Fri, Nov 20, 2009 at 10:20 AM, Martin Krasser
>>>>> <dev@martin-krasser.de>
>>>>> wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> I'm using the TransactionErrorHandler of Camel 2.0.0 and observe
an
>>>>>> unexpected transaction-outcome for handled errors. Using the
>>>>>> TransactionErrorHandler with the route
>>>>>>
>>>>>> onException(Exception.class).handled(true).process(...);
>>>>>> from("direct:test").transacted().processRef('myFailureProcessor');
>>>>>>
>>>>>> does actually a *commit* on the transaction manager (... the
>>>>>> mayFailureProcessor bean simply throws an Exception). Here I'd
>>>>>> definitly
>>>>>> expect a rollback. I also tried to make an explicit rollback in the
>>>>>> exception handler:
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> Yes of course it will commit because you have the local
>>>>> onException(Exception.class).handled(true) which intercepts the
>>>>> exception and handle it.
>>>>> Remove it all together and the transaction will rollback.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> onException(Exception.class).handled(true).process(...).rollback();
>>>>>> from("direct:test").transacted().processRef('myFailureProcessor');
>>>>>>
>>>>>> This rolls back the transaction but a new exception is thrown
>>>>>> (TransactedRuntimeCamelException). This is somewhat unexpected too
>>>>>> because
>>>>>> handled(true) is used.
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> No it not because you add the rollback() in the end which causes a new
>>>>> exception to be set and rollback the transaction anyway.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Is this really the intended behaviour of the TransactionErrorHandler
>>>>>> or
>>>>>> is
>>>>>> it a bug?
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> No its not a bug. You can mix and match transacted routes with the
>>>>> error handling in Camel using the onException clauses.
>>>>>
>>>>> However in most cases with transacted routes you would normally not
>>>>> use onException() but they are at your disposal if you need fine
>>>>> grained control.
>>>>> Or even want local retry in a transacted route, e.g. try uploading to
>>>>> FTP server 3 times etc.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> Martin
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>>
>>
>>
>>
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message