camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Mithe <jon.mi...@gmail.com>
Subject Exception handling
Date Fri, 18 Jul 2014 15:57:26 GMT
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.

Mime
View raw message