Preventing duplicate invocation of routing logic
When dealing with external systems, it is often necessary to ensure that the same request is not sent multiple times—a process often called deduplication.
Camel implements the Idempotent Consumer EIP, which allows you to mark a segment of a route as callable only once for each unique message. This is useful if it is possible for your route to receive duplicate messages, either from an upstream system or from the underlying infrastructure (for example, through a message queue configured for redelivery on failure), and you want to protect routing logic that is intolerant of duplicates.
This recipe explains how to make portions of your route idempotent in Camel.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.transactions.idempotentconsumer
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with idempotentConsumer
.
How to do it...
In order to use an Idempotent consumer in...