When using transactions, do you mean

transacted() in the route (eg transaction error handler)
Then the point of that is that it either commit or rollback. And that
you often have some transaction support from the external system, like
JMS, JDBC, etc.
Then you should not really use onException and Camel error handler,
but rely on transaction as-is.

And btw when an exception occur you can always access it via the
exchange property
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class));



On Mon, Jan 18, 2021 at 1:28 PM Marcus Ionker <[email protected]> wrote:
>
> Hello,
>
> I have a main processing route with multiple onException clauses with 
> useOriginalMessage. So that the errorhandler route knows what error occurred 
> in the main processing route, I wanted to set a onPrepareFailure. 
> Unfortunately you cannot set this value in the onException clause. Therefore 
> is the following the right way to do it?
>
> from(timer("myTimer").period(10000))
>                 .errorHandler(defaultErrorHandler().onPrepareFailure(new 
> Processor() {
>                         public void process(Exchange exchange) throws 
> Exception {
>                 exchange.getIn().setHeader("FailureException", 
> exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class));
>         }}))
>                 
> .onException(Exception.class).handled(true).useOriginalMessage().to(seda("mySeda")).end()
>         .setBody(constant("changed"))
>         .validate(body().isEqualTo("original"))
>         .to("stream:out");
>
> However, how do you do this in a route with transactions enabled? How would 
> can you simply add the processor to the default error handler that is 
> automatically setup for the route?
>
> The other solution I considered was using useOriginalBody, but this method is 
> commented that it is deprecated?
>
> Regards,
> Marcus Ionker
>
>
>
>
>
>
> Marcus Ionker
> Product Line Manager
>
> Phone: +49 89 5528-1202
> Fax: +49 89 1250400-1202
> Mobile: +49 176 15528012
> Email: [email protected]<mailto:[email protected]>
>
> -------------------------------------------------------------------------------------------------------
> Retarus Blog
> Stay up to date and read our latest blog 
> posts<https://www.retarus.com/blog/en/>.
> -------------------------------------------------------------------------------------------------------
>
> retarus GmbH. Aschauer Stra?e 30, 81549 M?nchen, Germany. 
> www.retarus.com<https://www.retarus.com>
>
>
>
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to