このコンテンツは選択した言語では利用できません。

14.4. Configuring JMS Transactions


Overview

CXF 3.0 supports both local JMS transactions and JTA transactions on CXF endpoints, when using one-way messaging.

Local transactions

Transactions using local resources roll back the JMS message only when an exception occurs. They do not directly coordinate other resources, such as database transactions.
To set up a local transaction, configure the endpoint as you normally would, and set the property sessionTrasnsacted to true.
Note
For more information on transactions and pooling, see the Red Hat JBoss Fuse Transaction Guide.

JTA transactions

Using JTA transactions, you can coordinate any number of XA resources. If a CXF endpoint is configured for JTA transactions, it starts a transaction before calling the service implementation. The transaction will be committed if no exception occurs. Otherwise, it will be rolled back.
In JTA transactions, a JMS message is consumed and the data written to a database. When an exception occurs, both resources are rolled back, so either the message is consumed and the data is written to the database, or the message is rolled back and the data is not written to the database.
Configuring JTA transactions requires two steps:
  1. Defining a transaction manager
    • bean method
      • Define a transaction manager
        <bean id="transactionManager" 
           class="org.apache.geronimo.transaction.manager.GeronimoTransactionManager"/>
        Copy to Clipboard Toggle word wrap
      • Set the name of the transaction manager in the JMS URI
        jms:queue:myqueue?jndiTransactionManager=TransactionManager
        Copy to Clipboard Toggle word wrap
        This example finds a bean with the ID TransactionManager.
    • OSGi reference method
      • Look up the transaction manager as an OSGi service using Blueprint
        <reference id="TransactionManager" interface="javax.transaction.TransactionManager"/>
        Copy to Clipboard Toggle word wrap
      • Set the name of the transaction manager in the JMS URI
        jms:jndi:myqueue?jndiTransactionManager=java:comp/env/TransactionManager
        Copy to Clipboard Toggle word wrap
        This example looks up the transaction manager in JNDI.
  2. Configuring a JCA pooled connection factory
    Using Spring to define the JCA pooled connection factory:
    <bean id="xacf" class="org.apache.activemq.ActiveMQXAConnectionFactory">
      <property name="brokerURL" value="tcp://localhost:61616" />
    </bean>
    
    <bean id="ConnectionFactory" class="org.apache.activemq.jms.pool.JcaPooledConnectionFactory">
      <property name="transactionManager" ref="transactionManager" />
      <property name="connectionFactory" ref="xacf" />
    </bean>
    Copy to Clipboard Toggle word wrap
    In this example, the first bean defines an ActiveMQ XA connection factory, which is given to a JcaPooledConnectionFactory. The JcaPooledConnectionFactory is then provided as the default bean with id ConnectionFactory.
    Note that the JcaPooledConnectionFactory looks like a normal ConnectionFactory. But when a new connection and session are opened, it checks for an XA transaction and, if found, automatically registers the JMS session as an XA resource. This allows the JMS session to participate in the JMS transaction.
    Important
    Directly setting an XA ConnectionFactory on the JMS transport will not work!
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat