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.

Get Apache Camel Developer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.