Retrying an operation
Sometimes the best way to fix an error that was triggered when invoking a service is to try sending it again, as the backend infrastructure may be temporarily unavailable. Camel makes it easy to specify policies that automatically retry making calls before flagging a message as an error. This recipe will show some of the ways in which you can control the retry policies for your integration routes.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.error.retry
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with retry
.
How to do it...
In the XML DSL, define an errorHandler
element within the camelContext
element, and reference its id
with the camelContext
element's errorHandlerRef
attribute. Within the errorHandler
element, create a child redeliveryPolicy
element, which provides the maximumRedeliveries
and redeliveryDelay
attributes, among many other options. This will set the base error handler...