JAVA - Spring Integration Flow Transaction + com.atomikos.icatch.HeurHazardException:启发式异常

时间:2015-10-16 17:25:40

标签: activemq spring-integration ibm-mq spring-transactions atomikos

我正在尝试使事务整个Spring集成流程,流程从适配器到IBM MQ Queue开始,然后我们有一个复杂的流程与ActiveMQ队列,我得到一个com.atomikos。 icatch.HeurHazardException:当atomikos试图注册资源时的启发式异常。

这是我的applicationContext.xml。

<bean id="mqConnectionFactory"                     class="com.ibm.mq.jms.MQQueueConnectionFactory">
    <property name="hostName" value="${ibm.mq.connection.url}" />
    <property name="port" value="${ibm.mq.connection.port}" />
    <property name="transportType" value="${ibm.mq.conection.type}" />
    <property name="queueManager" value="${ibm.mq.conection.queuemanager}"          />
    <property name="channel" value="${ibm.mq.conection.channel}" />
</bean>

<bean id="mqConnectionFactoryCache"
    class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory" ref="mqConnectionFactory" />
    <property name="sessionCacheSize" value="10" />
    <property name="cacheConsumers" value="true"></property>
</bean>

<bean id="mqInboundQueue" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg value="${ibm.mq.conection.queue}" />
</bean>

<bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
    <!-- brokerURL -->
    <property name="brokerURL" value="${active.mq.connection.url}" />
    <property name="redeliveryPolicy" ref="amqRedeliveryPolicy"></property>
</bean>

<bean id="amqRedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
    <property name="maximumRedeliveries" value="5"></property>
    <property name="redeliveryDelay" value="1000"></property>
</bean>

<bean id="atmConnectionFactory"   class="com.atomikos.jms.AtomikosConnectionFactoryBean"  
          init-method="init" destroy-method="close"> 
  <property name="uniqueResourceName" value="INPUT" /> 
  <property name="xaConnectionFactory" ref="amqConnectionFactory" /> 


                                             

<bean id="inputChannelQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="INPUT" />
</bean>

<jms:channel id="inputChannel" queue="inputChannelQueue">
    <jms:interceptors>
        <int:wire-tap channel="inputLoggingChannel"/>
    </jms:interceptors>
</jms:channel>


<jms:message-driven-channel-adapter id="MQInboundGateway"
                                     connection-factory="mqConnectionFactoryCache"
                                     destination="mqInboundQueue"   
                                     channel="inputChannel"
                                     concurrent-consumers="20"
                                      cache-level="3" acknowledge="transacted" />

.
. //OTHER SPRING INTEGRATION ELEMENTS
.
<int:channel id="concentradorOutputChannel" /> //Final Channel to the output adapter.

<!-- ATOMIKOS BEANS -->
<bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp"  init-method="init" destroy-method="shutdownForce">
    <constructor-arg>
    <!-- IMPORTANT: specify all Atomikos properties here -->
        <props>
            <prop key="com.atomikos.icatch.service">
            com.atomikos.icatch.standalone.UserTransactionServiceFactory
            </prop>
        </props>
    </constructor-arg>      
</bean>

<bean id="AtomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"    init-method="init" destroy-method="close" depends-on="userTransactionService">
    <property name="startupTransactionService" value="false" />
    <property name="forceShutdown" value="false" />
</bean>

<bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"   depends-on="userTransactionService">
    <property name="transactionTimeout" value="300" />
</bean>

<!-- //================= TX BEANS  =================// -->

 <bean id="JtaTransactionManager"   class="org.springframework.transaction.jta.JtaTransactionManager"   depends-on="userTransactionService">
    <property name="transactionManager" ref="AtomikosTransactionManager" />
    <property name="userTransaction" ref="AtomikosUserTransaction" />
 </bean>

<aop:config>
    <aop:advisor advice-ref="txAdvice" pointcut="bean(inputChannel)" />
</aop:config>

<tx:advice id="txAdvice" transaction-manager="JtaTransactionManager">
    <tx:attributes>
        <tx:method name="send" />
    </tx:attributes>
</tx:advice>

这是一个例外:

INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING   core version: 3.9.3
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING  com.atomikos.icatch.automatic_resource_registration = true
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.client_demarcation = false
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.threaded_2pc = false
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.serial_jta_transactions = true
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.serializable_logging = true
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.log_base_dir = .\
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.max_actives = 50
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.checkpoint_interval = 500
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.enable_logging = true
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.output_dir = .\
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.log_base_name = tmlog
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.max_timeout = 300000
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.tm_unique_name = 10.200.204.8.tm
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING java.naming.factory.initial = com.sun.jndi.rmi.registry.RegistryContextFactory
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING java.naming.provider.url = rmi://localhost:1099
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING  com.atomikos.icatch.service =  com.atomikos.icatch.standalone.UserTransactionServiceFactory
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.force_shutdown_on_vm_exit = false
INFO  com.atomikos.icatch.config.imp.AbstractUserTransactionService USING com.atomikos.icatch.default_jta_timeout = 10000
WARN  com.atomikos.datasource.xa.XAResourceTransaction XAResourceTransaction  10.200.204.8.tm001540002610.200.204.8.tm157: no XAResource to commit - the   required resource is probably not yet intialized?
WARN  com.atomikos.icatch.imp.CommitMessage Unexpected error in commit
com.atomikos.icatch.HeurHazardException: Heuristic Exception
at com.atomikos.datasource.xa.XAResourceTransaction.commit(XAResourceTransaction.java:707)
at com.atomikos.icatch.imp.CommitMessage.send(CommitMessage.java:72)
at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:83)
at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:79)
at com.atomikos.icatch.imp.Propagator.submitPropagationMessage(Propagator.java:58)
at com.atomikos.icatch.imp.HeurHazardStateHandler.onTimeout(HeurHazardStateHandler.java:131)
at com.atomikos.icatch.imp.CoordinatorImp.alarm(CoordinatorImp.java:933)
at com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:112)
at com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:99)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

我需要从inputChannel到concentradorOutputChannel的整个流程都在TX内。

感谢您的帮助。

1 个答案:

答案 0 :(得分:8)

解决了,只需删除文件tmlog.lck和tmlog6.log