JTA
JVM since1.0.0 Native since1.0.0
Enclose Camel routes in transactions using Java Transaction API (JTA) and Narayana transaction manager
Maven coordinates
Or add the coordinates to your existing project:
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jta</artifactId>
</dependency>
Check the User guide for more information about writing Camel Quarkus applications.
Usage
This extension should be added when you need to use the transacted()
EIP in the router. It leverages the transaction capabilities provided by the narayana-jta extension in Quarkus.
Refer to the Quarkus Transaction guide for the more details about transaction support. For a simple usage:
from("direct:transaction")
.transacted()
.to("sql:INSERT INTO A TABLE ...?dataSource=#ds1")
.to("sql:INSERT INTO A TABLE ...?dataSource=#ds2")
.log("all data are in the ds1 and ds2")
Support is provided for various transaction policies.
Policy | Description |
---|---|
| Support a current transaction; throw an exception if no current transaction exists. |
| Do not support a current transaction; throw an exception if a current transaction exists. |
| Do not support a current transaction; rather always execute non-transactionally. |
| Support a current transaction; create a new one if none exists. |
| Create a new transaction, suspending the current transaction if one exists. |
| Support a current transaction; execute non-transactionally if none exists. |