Conditional retry

If your error retry logic requires more sophistication than can be expressed by number of retries with delays, then conditional retry can help. It allows you to associate a predicate (expression that evaluates to a boolean) with an error handler, or onException block, that is used to decide how long to continue retrying. This gives you much finer control over the number of retry attempts by using any of Camel's Expression Languages, including calling out to a Java method, to decide if it should keep retrying delivery of the message.

This recipe will show you how to use the Simple Expression Language to make a redelivery decision based on the content of the message.

Getting ready

The Java code for this recipe is located in the

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.