Hi

Favor using getIn to change the message body.

See this FAQ
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html



On Fri, Jul 18, 2014 at 5:57 PM, Jon Mithe <[email protected]> wrote:
> Hello,
>
> I've set up a request-reply and I'm experimenting with exception handling
> but I cant see to get it to report properly.
>
> I've set up these routes:
>
>     from("seda:start")
>         .inOut("direct:externalService")
>         .to("stream:out");
>
>     from("direct:externalService").process(new MyProcessor());
>
> Where MyProcessor does: exchange.getOut().setBody(exchange.getIn().getBody()
> + " was processed!");
>
> That all works great, however, if I change MyProcessor to "throw new
> RuntimeException("oh noes");" then it it fails silently with no output.
>
> I can change my route to:
>
>         from("direct:externalService")
>
> .onException(Exception.class).bean(ExceptionHandler.class).to("stream:out").end()
>                 .process(new MyProcessor());
>
> ExceptionHandler.class has a method "public void handle(Exchange exchange,
> Exception e)".  I get the exception and the original exchange by the looks
> of it which is great.
>
> However, my original route specifying the inOut seems to receive no response
> or exception and seems its request is lost in the ether.
>
> I tried added some exchange.getOut().setBody("Error"); and
> exchange.getOut().setFault(true) but still nothing.
>
> I'm I doing something silly here?  I would have expected if an exception was
> thrown on the inOut route then the a response would automatically be
> generated saying fail.  I think I must be missing something.
>
> Thanks,
> Jon
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Exception-handling-tp5754013.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [email protected]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to