Customizing each redelivery attempt
Camel allows you to register a Processor instance with the redelivery policy that can change any part of the message and its headers before each redelivery attempt. This can help if there are ways you can tweak the message in response to certain errors.
This recipe will show you how to change the contents of the exchange during each redelivery attempt.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.error.retrycustom
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with retrycustom
.
How to do it...
Configure an error handler for redelivering a message, and set its onRedelivery
option to reference a Camel processer that you implement.
Implement a
org.apache.camel.Processor
that will get called to process the message before each redelivery attempt:import org.apache.camel.Exchange; import org.apache.camel.Processor; public class RetryCustomProcessor implements Processor { @Override...