이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 7. Camel Quarkus transaction guide


7.1. About the transaction guide

This guide provides information and instructions for implementing transactional applications with Red Hat build of Apache Camel for Quarkus.

7.2. JTA dependencies

In order to use camel-quarkus-jta, you need to include the following dependency in your pom.xml

<dependency>
  <groupId>org.apache.camel.quarkus</groupId>
  <artifactId>camel-quarkus-jta</artifactId>
</dependency>
Copy to Clipboard Toggle word wrap

This leverages quarkus-narayana-jta to provide JTA support in Camel.

7.2.1. Important configurations

There are some important quarkus.transaction-manager configurations you need to be aware of:

Expand
ConfigurationDefault valueDescriptionComment

.node-name

quarkus

Identifes the node. It needs to be unique and stable over both transaction manager and container restarts.

For more information, see Configuring transaction node name identifier in the Quarkus documentation.

.object-store.type

file-system

Configures where the transaction logs are stored - either in a directory (file-system) or in a database (jdbc).

For a cloud environment without access to persistent volumes, consider using the jdbc object store.

For more information, see Configure storing of Quarkus transaction logs in a database section in the Quarkus documentation

.enable-recovery

false

Enables recovery of pending transactions in case of a JVM crash or shutdown.

We recommend that you set it to true when you are using XA transactions in your application. Otherwise, pending transactions are lost in case of a JVM crash or shutdown.

7.3. Configuring transactional resources

7.3.1. JDBC Datasource configuration

To configure the datasource:

  1. Include the relevant jdbc extension by following the Configure datasources in Quarkus section in the Quarkus datasource guide.

The extensions are integrated with the Quarkus agroal extension to support pooling and XA transactions.

Optional

  1. If you want to use the datasource in a XA transaction, you must enable it:

    quarkus.datasource.jdbc.transactions = xa

    quarkus.datasource.<datasource-name>.jdbc.transactions = xa

    For more information, refer to the Narayana transaction manager integration section in the Quarkus datasource guide.

Warning

Do not mix using non-XA and XA datasource in a transaction.

It is not a transaction safe.

7.3.2. JMS Configuration

In order to use JMS with distributed transactions, you must do the the following:

  1. Use quarkus-pooled-jms to support pooling and transaction, by including the following dependency in your pom.xml:

    <dependency>
        <groupId>io.quarkiverse.messaginghub</groupId>
        <artifactId>quarkus-pooled-jms</artifactId>
    </dependency>
    Copy to Clipboard Toggle word wrap
  2. Enable XA support by setting .transaction to xa:

    quarkus.pooled-jms.transaction = xa

For more details, see Support for connection pooling and X/Open XA distributed transactions in the JMS extension documentation.

7.4. Examples

JPA and JMS

We use Narayana as the standalone JTA Transaction Manager implementation, and Hibernate as the JPA Adapter.

JMS and JPA: A Camel Quarkus example

Message Bridge

A basic REST endpoint is provided for users to dispatch a message to the IBM MQ queue. Messages from the IBM MQ are relayed to an ActiveMQ queue within an XA transaction. This example showcases the transaction functionality with rollback and recovery.

Message Bridge: A Camel Quarkus example

7.5. Transaction policies

There are six transaction policies:

Expand
PolicyDescriptionComment

PROPAGATION_MANDATORY

Support a current transaction; throw an exception if no current transaction exists.

 

PROPAGATION_NEVER

Do not support a current transaction; throw an exception if a current transaction exists.

 

PROPAGATION_NOT_SUPPORTED

Do not support a current transaction; rather always execute non-transactionally.

 

PROPAGATION_REQUIRED

Support a current transaction; create a new one if none exists.

Default

PROPAGATION_REQUIRES_NEW

Create a new transaction, suspending the current transaction if one exists.

 

PROPAGATION_SUPPORTS

Support a current transaction; execute non-transactionally if none exists.

 

For more details, see Using different transaction propagations in the Quarkus Transactional client documentation.

7.6. Known issues

7.6.1. Non-XA datasource compatibility

Since 3.8.4, there is a compatibility break issue when using non-XA datasource. For more information see the pull request 40365

맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat