public void testIssue() throws Exception { final Predicate fail = PredicateBuilder.or( header(Exchange.REDELIVERY_COUNTER).isNull(), header(Exchange.REDELIVERY_COUNTER).isLessThan(5)); RouteDefinition route = context.getRouteDefinitions().get(0); route.adviceWith( context, new RouteBuilder() { @Override public void configure() throws Exception { interceptSendToEndpoint("seda:*") .skipSendToOriginalEndpoint() .process( new Processor() { public void process(Exchange exchange) throws Exception { invoked.incrementAndGet(); if (fail.matches(exchange)) { throw new ConnectException("Forced"); } } }) .to("mock:ok"); } }); getMockEndpoint("mock:global").expectedMessageCount(0); getMockEndpoint("mock:ok").expectedMessageCount(1); getMockEndpoint("mock:exhausted").expectedMessageCount(0); template.sendBody("direct:start", "Hello World"); assertMockEndpointsSatisfied(); // 5 retry + 1 ok assertEquals(6, invoked.get()); }
protected Predicate createHandledPolicy() { // should NOT be handled by default for default error handler return PredicateBuilder.toPredicate(ExpressionBuilder.constantExpression(false)); }