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.

Reply via email to