camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jorabin <jo.ra...@wiforia.com>
Subject Dead Letter ErrorHandler and onException
Date Thu, 23 Jul 2015 16:24:07 GMT
As I understand it, if you have an exception handler then the dead letter
processing should not get invoked.
However, according to the tests below if you do not have some kind of
processor in the exception handler, the dead letter logic does in fact get
invoked.
Is this behavior by design? It is certainly very confusing, since two
exception handlers differing only in whether they contain a "log" or not
behave differently, as in the following unit test:
Thanks
    public static class InterestingException extends Exception {}    public
static class LessInterestingException extends Exception {}    RouteBuilder
errorHandlerRoute = new RouteBuilder() {        @Override        public void
configure() throws Exception {            from("direct:in")                   
.errorHandler(deadLetterChannel("direct:dlc"))                   
.onException(InterestingException.class)                       
.handled(true)                    .end()                   
.onException(LessInterestingException.class)                       
.handled(true)                        .log("handling less interesting
exception")                    .end()                    .choice()                   
.when(simple("${header.interesting}"))                       
.throwException(new InterestingException())                   
.when(simple("${header.lessInteresting}"))                       
.throwException(new LessInterestingException())                   
.endChoice();            from("direct:dlc")                    .log("I am
the dead letter channel")                    .setBody(constant("Dead
Letter"));        }    };    @Test    public void test5() throws Exception {       
context().addRoutes(errorHandlerRoute);        String answer =
template().requestBodyAndHeader("direct:in", "", "interesting", true,
String.class);        assertEquals("Dead Letter", answer);        answer =
template().requestBodyAndHeader("direct:in", "", "lessInteresting", true,
String.class);        assertNotEquals("Dead Letter", answer);    }




--
View this message in context: http://camel.465427.n5.nabble.com/Dead-Letter-ErrorHandler-and-onException-tp5769828.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message