JAVA - Spring Integration Flow Transaction + com.atomikos.icatch.HeurHazardException:启发式异常
Posted
技术标签:
【中文标题】JAVA - Spring Integration Flow Transaction + com.atomikos.icatch.HeurHazardException:启发式异常【英文标题】:JAVA - Spring Integration Flow Transaction + com.atomikos.icatch.HeurHazardException: Heuristic Exception 【发布时间】:2016-01-15 13:04:54 【问题描述】:我正在尝试使事务成为 Spring 集成的整个流程,该流程从一个 IBM MQ 队列的适配器开始,然后我们有一个带有 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 内。
感谢您的帮助。
【问题讨论】:
已解决,只需要删除tmlog.lck和tmlog6.log文件 很高兴听到!请将您的解决方案描述为答案并接受它以从“未回答”堆中过滤此问题 【参考方案1】:已解决,只需要删除文件 tmlog.lck 和 tmlog6.log
【讨论】:
以上是关于JAVA - Spring Integration Flow Transaction + com.atomikos.icatch.HeurHazardException:启发式异常的主要内容,如果未能解决你的问题,请参考以下文章
Spring Integration Java DSL:如何使用 channelMapping 方法路由到标题中名称的通道?
在 java 1.7 中将 JMS 出站通道适配器转换为等效的 Spring Integration DSL
Spring的Data Access/Integration(意思:整合,一体化)包含的模块
spring integration:如何从 Spring Controller 调用 Spring Integration?