camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Zapletal <>
Subject Returning a custom response (custom fault message) when a transaction fails
Date Mon, 21 Feb 2011 17:09:17 GMT
Dear folks,

My questions relates to a transacted route as it is described in the 
Camel in Action Book in Section 9.4.3 (Returning a custom response) - my 
goal is, however, to return a web service fault (instead of regular 
response message) _and_ rollback the route.

The situation is as follows: I have a transacted camel route exposed as 
a web service. In case, an exception happens on the route, the exception 
is caught using an onException block and a custom response is returned.

My transaction handling behavior looks quite similar as in the book:

<transform><method bean="order" method="replyError"/></transform>
<rollback markRollbackOnly="true"/>

However, I do not want to return a "regular response message" containing 
an error code, but a web service fault. I am doing this using code as 
follows in my corresponding bean:

exchange.getOut().setBody(new Failure(...)); // my JAXB fault type

My problem is now that when calling setFault(true) on the out messsage 
the transaction is not rolled back according to the logs 
(DEBUG:Transaction commit (0x2b105d) for ExchangeId: ID-4711)

When I return a regular out message, everything works as expected and I 
see in the logs that the transaction is rolled back. I've already tried 
to use just rollback() instead of markRollbackOnly(), but without any 

Any help would be appreciated.


View raw message