camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Minh Tran <darth.minhs...@gmail.com>
Subject Re: dynamicRouter and redelivery
Date Fri, 20 Feb 2015 09:30:26 GMT
Can anyone help? Seems like redelivery with dynamicRouters doesn’t seem possible.

On 18 Feb 2015, at 2:24 pm, Minh Tran <darth.minhster@gmail.com> wrote:

> 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?


Mime
View raw message