You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Martin Lichtin <li...@yahoo.com.INVALID> on 2017/03/31 12:18:59 UTC

Using rollback() inside onException

Hi
Wanted to ask, what would be a reason to explicitly call rollback() in an onException().

For example, would this make sense?


.onException(Exception.class).rollback().end()

I'm under the expression above line could just be left out, as Camel anyway lets 

the exception up and that will cause the transaction to roll back.

Re: Using rollback() inside onException

Posted by Martin Lichtin <li...@yahoo.com.INVALID>.
Thanks, indeed it all works as expected without using rollback().
I had cases of onException().handled(true)....rollback().end() that could be simplified to onException()....end().


On 31.03.2017 17:10, Quinn Stevenson wrote:
> I don\u2019t this this would make sense for handling java.lang.Exception - I think you\u2019re right about Camel doing the same action by default.
>
> I guess if there was some other exception you were handling (i.e. handled(true)), you may want to call rollback - but I can\u2019t think of a really good example right of hand.  The place\u2019s I\u2019ve used rollback() (actually markRollbackOnly() - I\u2019ve never used rollback()) are in routes where something besides an exception determines whether or not I want to rollback the transaction.
>
> For what it\u2019s worth ...
>
>
>> On Mar 31, 2017, at 6:18 AM, Martin Lichtin<li...@yahoo.com.INVALID>  wrote:
>>
>> Hi
>> Wanted to ask, what would be a reason to explicitly call rollback() in an onException().
>>
>> For example, would this make sense?
>>
>>
>> .onException(Exception.class).rollback().end()
>>
>> I'm under the expression above line could just be left out, as Camel anyway lets
>>
>> the exception up and that will cause the transaction to roll back.


Re: Using rollback() inside onException

Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
I don’t this this would make sense for handling java.lang.Exception - I think you’re right about Camel doing the same action by default.

I guess if there was some other exception you were handling (i.e. handled(true)), you may want to call rollback - but I can’t think of a really good example right of hand.  The place’s I’ve used rollback() (actually markRollbackOnly() - I’ve never used rollback()) are in routes where something besides an exception determines whether or not I want to rollback the transaction.

For what it’s worth ...


> On Mar 31, 2017, at 6:18 AM, Martin Lichtin <li...@yahoo.com.INVALID> wrote:
> 
> Hi
> Wanted to ask, what would be a reason to explicitly call rollback() in an onException().
> 
> For example, would this make sense?
> 
> 
> .onException(Exception.class).rollback().end()
> 
> I'm under the expression above line could just be left out, as Camel anyway lets 
> 
> the exception up and that will cause the transaction to roll back.