Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-681

[docs] Wrong ConnectionFactory used in XA sample configuration.

XMLWordPrintable

    • % %
    • Todo

      The page Sample JMS XA Configuration, example 16 provides the full configuration for configuring XA transactions for JMS endpoints. However it has a mistake:

      On the documentation there is this definition

      <bean id="jmsXaPoolConnectionFactory" class="org.apache.activemq.pool.XaPooledConnectionFactory"> 
        <property name="maxConnections" value="200" /> 
        <property name="connectionFactory" ref="jmsXaConnectionFactory" />
        <property name="transactionManager" ref="osgiJtaTransactionManager" />
      </bean>
      

      but it should rather be

      <bean id="jmsXaPoolConnectionFactory" class="org.apache.activemq.pool.JcaPooledConnectionFactory"> 
        <property name="maxConnections" value="200" /> 
        <property name="connectionFactory" ref="jmsXaConnectionFactory" />
        <property name="transactionManager" ref="osgiJtaTransactionManager" />
        <property name="name" value="activemq.default" />
      </bean>
      

      In order for the Aries transaction manager to properly write its transaction log (which is needed if you want to recover transactions after a crash), the JcaPooledConnectionFactory is needed and must be configured with a name property whose value must match the resourceName property of the resource manager definition:

      <bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager" init-method="recoverResource"> 
        <property name="transactionManager" ref="osgiJtaTransactionManager" />
        <property name="connectionFactory" ref="jmsXaPoolConnectionFactory" />
        <property name="resourceName" value="activemq.default" /> 
      </bean>
      

      With the currently documented configuration there will be an error thrown at the time of committing the transaction because the Geronimo transaction manager is unable to write the transaction log as not every XA resource has a unique name associated. This is done by using the JcaPooledConnectionFactory and setting the name property.

      There is a fully working example configuration available at
      https://github.com/tmielke/fuse-demos/blob/master/Camel/Camel-JMS-JDBC-XA-TX/routing/src/main/resources/OSGI-INF/blueprint/camel-context.xml

              fbolton@redhat.com Fintan Bolton (Inactive)
              rhn-support-tmielke Torsten Mielke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: