1

采取的步骤:

  1. 遵循链接 http://www.atomikos.com/Documentation/Tomcat7Integration35中提到的所有步骤 。将“atomikos-integration-extension-3.7.1-20120529.jar”复制到 TOMCAT_HOME/lib 文件夹中。

    湾。服务器.xml

    C。上下文.xml

    d。添加了所有必需的事务 jar。还有交易属性:

  2. 在代码中完成的更改,

一个。交易.xml:

<bean id="UserTransactionBean"
    class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/UserTransaction"></property>
</bean>

<!--  One Bean that applies Transaction semantics as well as Retry Logic. It only supports
PROPOGATION_REQUIRED SEMANTICS.
-->
<bean id="TstTransactionInterceptor"
    class="com.test.transaction.interceptor.TstTransactionInterceptor">

    <property name="exceptionHandler" ref="TstRuntimeExceptionHandler" />

    <!--  Max Times to Retry a Transaction eligible for Retry -->
    <property name="maxRetryAttempts" value="1" />

    <!--  Time to wait between retries of eligible transactions ( in seconds)
    -->
    <property name="waitTimeBetweenRetries" value="2"></property>
    <property name="userTransaction" ref="UserTransactionBean" />

    <!--  List of methods that transaction interceptor will not apply declarative transactions for
    -->
    <property name="excludedMethodList">
        <list>
            <value>toString</value>
            <value>equals</value>
        </list>
    </property>
</bean>

<bean id="JTATxManager"
    class="org.springframework.transaction.jta.JtaTransactionManager">
    <property name="autodetectTransactionManager" value="true" />
</bean>

<bean id="SpringTransactionInterceptor"
    class="org.springframework.transaction.interceptor.TransactionInterceptor">
    <property name="transactionManager">
        <ref bean="JTATxManager" />
    </property>
    <property name="transactionAttributeSource">
        <ref bean="TransactionAttributes" />
    </property>
</bean>

ISSUE: 只有当我们尝试将消息推送到队列时,我们总是在日志中找到 No JTA TransactionManager。我们能够成功地进行数据库调用:

-- checkUserTransactionAndTransactionManager, No JTA TransactionManager found: transaction suspension not available

-- WARNING: atomikos connection pool 'QCF_MQSeries_XA_RMI': error creating proxy of connection atomikos pooled connection for resource QCF_MQSeries_XA_RMI
    [3/28/14 14:26:25:052 CDT] 00000137 ConnectionPoo W com.atomikos.logging.JULLogger logWarning atomikos connection pool 'QCF_MQSeries_XA_RMI': error creating proxy of connection atomikos pooled connection for resource QCF_MQSeries_XA_RMI
                             com.atomikos.datasource.pool.CreateConnectionException: atomikos pooled connection for resource QCF_MQSeries_XA_RMI: connection is erroneous

--  WARN   logWarning, atomikos MessageConsumer proxy for com.ibm.mq.jms.MQQueueReceiver@73085060: The JMS session you are using requires a JTA transaction context for the calling thread and none was found.
    WARN   logWarning, Error in proxy
    com.atomikos.jms.AtomikosTransactionRequiredJMSException: The JMS session you are using requires a JTA transaction context for the calling thread and none was found.
    Please correct your code to do one of the following: 
    1. start a JTA transaction if you want your JMS operations to be subject to JTA commit/rollback, or
    2. increase the maxPoolSize of the AtomikosConnectionFactoryBean to avoid transaction timeout while waiting for a connection, or
    3. create a non-transacted session and do session acknowledgment yourself, or
    4. set localTransactionMode to true so connection-level commit/rollback are enabled.
        at com.atomikos.jms.AtomikosTransactionRequiredJMSException.throwAtomikosTransactionRequiredJMSException(AtomikosTransactionRequiredJMSException.java:40)

如果有人遇到过这个问题,请告诉我们您是如何解决的。

4

0 回答 0