0

I've been following the examples of sending a message to the Dead Letter Channel but haven't worked out how to test this. Messages do get routed to the DLC but I want to make sure this is tested.

For example, how would I test that the message is received on the log:dead endpoint. This code is in a test class extending from CamelTestSupport:

@Override
protected RouteBuilder createRouteBuilder() throws Exception {

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            errorHandler(deadLetterChannel("log:dead?level=ERROR").logHandled(true)); 

            from("direct:testdlc").process(new Processor() {
                @Override
                public void process(Exchange exchange) throws Exception {
                    throw new IllegalArgumentException("kaboom!");
                }
            }).to("mock:file");
        }
    };
}

One option would be to write it to a new route, but I was hoping to use the out-of-the-box logger.

1 Answers1

0

You could send the message to the mock endpoint after logging.

from("log:dead?level=ERROR").to("mock:logger");
Matthew Wilson
  • 2,045
  • 14
  • 27