On Sat, Sep 1, 2012 at 8:49 PM, nilspreusker <[email protected]> wrote:
> Hi there,
>
> I'm wondering whether it is possible to write a component with a consumer
> that synchronously processes incoming messages. What I would like to achieve
> is that, if an exception occurs during the processing of the route, the
> exception is propagated back to the caller rather than passed on to camel's
> built in default error handler.
>
> So if I have a route like this:
> from("myComponent://in).beanRef("beanThatTrowsAnException");
>
> ...which is invoked within a transaction, and the referenced bean throws an
> exception, I'd like camel to throw the exception back to the caller (i.e.
> the consumer) in order to handle it there or roll back the transaction.
>
> Is there a way of doing that or is there even a component that does
> something similar so I could have a look at how it is done there?
>

This is how it works in Camel. The consumer kicks off the routing, when you
use the processor to process the Exchange, the consumer has created.

You can do this synchronously

try {
   getProcessor().process(exchange);
} catch (Exception e) {
   exchange.setException(e);
}

if (exchange.getException() != null) {
   // some exception happened
}


Then in your Camel routes you should of course not use an error
handler that will handle the exception such
as the DeadLetterChannel etc.



> Cheers!
> Nils
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Synchronous-consumer-tp5718500.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to