WebSphere MQ and Atomikos - Messages Lost on process termination

China☆狼群 提交于 2020-01-14 10:30:08

问题


My app (a spring message listener) reads from a queue and writes to the database in a single transaction. I use Atomikos to provide the XA transaction behaviour. When the app is abruptly terminated with kill statements for example, I see messages are lost. Is there any specific configuration I need to use? Should the queues be persistent? Currently the queues are non-persistent. My MQ version is v7.1.

Spring config for listener container looks like:

<bean id="listenerContainer" class="com.miax.test.TestListenerMDPImpl" autowire="byName">
    <property name="connectionFactory" ref="mqConnFactory" />
    <property name="destinationName" value="QUEUE" />
    <property name="messageListener" ref="listenerAdapter" />
    <property name="transactionManager" ref="jtaTransactionManager" />
    <property name="sessionTransacted" value="true" />
    <property name="concurrentConsumers" value="1" />
    <!-- receive time out, should be less than tranaction time out -->
    <property name="receiveTimeout" value="3000" />
    <!-- retry connection every 1 seconds -->
    <property name="recoveryInterval" value="1000" />
    <property name="autoStartup" value="true" />
    <property name="sessionAcknowledgeMode" value="0" />
</bean>

Any other info will be given as needed.

Thanks.


回答1:


The client you are using must be the Extended Transactional Client if downloaded prior to May of this year. Any of the V7.0.1 and higher clients as of May 2012 have the XA capability built in. If in doubt, go download a current release of the WMQ client and install.

Second, the XA transaction manager must have it's own connection to the queue manager independent of the application. This is so that it can connect and reconcile the transactions if the application fails to restart. To do this, the transaction manager must be configured with an XX_OPEN string and a switch file as described in the Infocenter topic Configuring XA-compliant transaction managers.

For what its worth, there is no such thing as a persistent queue in WMQ. It is the messages themselves that are persistent (or not). For more on that, please see my blog post on the topic. This is a rather important topic because when people assume that the queue itself is persistent they tend to devise solutions that produce unexpected results. Please read the blog post!



来源:https://stackoverflow.com/questions/12461572/websphere-mq-and-atomikos-messages-lost-on-process-termination

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!