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

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

Red Hat 소개

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

Theme

© 2025 Red Hat