Idempotency inside transactions
This recipe will show you how to wire up an idempotent consumer that uses a database as its repository for previously seen messages, within a route that uses transaction management with that same database.
This setup is used so that the persistence of message IDs by an idempotent consumer is not affected by the results of any database transactions in progress within the same route.
The net effect is a combination of the behaviors that we have already seen in the Using transactions with a database and Preventing duplicate invocation of routing logic recipes.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.transactions.idempotentconsumerintransaction
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with idempotentConsumerInTransaction
.
How to do it...
To get idempotency inside transactions working, you need to perform the following high-level steps:
Set up transactional access over a
DataSource...