Limiting the scope of a transaction

The technique shown in the Using transactions with a database recipe used the transacted DSL statement to initiate a transaction. Using this approach, the transaction is committed when the exchange's processing completes. This recipe will show you how you can control the scope of transactions in a much more granular fashion using the policy statement.

Getting ready

The Java code for this recipe is located in the org.camelcookbook.transactions.transactionpolicies package. The Spring XML files are located under src/main/resources/META-INF/spring and prefixed with transactionPolicies.

How to do it...

Set up a SpringTransactionPolicy associated with a transaction manager as shown in the Using transactions with a database ...

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.