camel redeliver : How do I retry processing a message from a certain point back
<p>I wanted to apply re-deliver and use Dead Letter Channel. So found this very useful apache-camel FAQ <a href="http://camel.apache.org/how-do-i-retry-processing-a-message-from-a-certain-point-back-or-an-entire-route.html" rel="nofollow">link</a>. I followed the steps as mentioned in this website.</p>

<p>I added a little more logic, the code is available in <a href="https://github.com/RakeshBhat/rb-simplecamel-example/" rel="nofollow">github</a> .</p>

<p>Basically, as per the FAQ, we have to split the routes, such that(as mentioned in the FAQ) the camel can handle any exception in the sub route.
Here is the code (Camel Route):</p>

<pre><code>    @Override
public void configure() throws Exception {
    errorHandler(deadLetterChannel("mock:error")
            .logExhaustedMessageBody(true)
            .logExhausted(true)
            .logRetryStackTrace(true)
            .maximumRedeliveries(3)
            .redeliveryDelay(1000)
            .backOffMultiplier(2)
            .useOriginalMessage()
            .useExponentialBackOff());

    from("direct:start")
    .log("Dump incoming body: " + body())
    .to("direct:sub")
    .end();

    from("direct:sub")
    .errorHandler(noErrorHandler())
    .process(new SubRouteProcessor())
    .log("Dump incoming body: "+ body())
    .process(new NewSubRouteProcessor())
    .transform(body().append("Modified Data !"))
    .to("mock:result");
}
</code></pre>

<p>I wrote a simple unit test, to trigger the exception, hence the redeliver code is executed.</p>

<p><strong>Now the difficulty/problem</strong>: The expected behavior is to do only 3 redeliver attempts, with 1000 millis delay and ExponentialBackOff.</p>

<p>However, the Test runs forever, keeps on doing the re-delivery with exponential delay. If I remove/comment the 2 processor calls, the code does run fine, means on exception, it does only 3 retries.</p>

<p>Could you please help to understand, 
1) what is wrong in this code/route?
2) what is causing code to run forever?
3) why removing these processors, it works,retry happens for 
said number of times only?</p>

<p>I just want - when ever the "direct:sub" throws "exception", the control goes back to "direct:start", re-try processing message from a certain point.</p>

<p>Thank you !!</p>