Hi

I seem to be having an issue with redelivery for an endpoint being called 
within a dynamic router in Camel 2.14.1. My endpoint is never called more than 
once.

Here is my route

from("direct:start").onException(IOException.class).maximumRedeliveries(-1).end()

.dynamicRouter().method(Router.class).to("mock:end”);

Here is my Router class, very similar to the example provided in the docs using 
an invoked property on the exchange.

public class Router {
        public String route(Exchange exchange) {
                Boolean invoked = exchange.getProperty("invoked", 
Boolean.class);
                if (invoked == null) {
                        exchange.setProperty("invoked", true);
                        return "mock:route";
                } else
                        return null;
        }
}

Here is my test method

        @Produce(uri = "direct:start")
        private ProducerTemplate producerTemplate;

        @EndpointInject(uri = "mock:end")
        private MockEndpoint end;

        @EndpointInject(uri = "mock:route")
        private MockEndpoint route;

        @Test
        public void test_exception() throws InterruptedException {
                route.whenExchangeReceived(1, new Processor() {

                        @Override
                        public void process(Exchange exchange) throws Exception 
{
                                exchange.setException(new IOException());
                        }
                });
                route.whenExchangeReceived(2, new Processor() {

                        @Override
                        public void process(Exchange exchange) throws Exception 
{
                                exchange.getIn().setBody("mock route");
                        }
                });
                route.expectedBodiesReceived("before", "before");

                end.expectedBodiesReceived(“mock route");
                producerTemplate.sendBody("before");
                route.assertIsSatisfied();
                end.assertIsSatisfied();
        }

I believe the problem is because the invoked property on the exchange must be 
surviving the redelivery and hence ends the dynamic route prematurely. How do I 
ensure it gets removed so the dynamic route redelivers to the mock:route?

Reply via email to