本文介绍了WebSphere MQ和Atomikos-进程终止时消息丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序(春季消息侦听器)从队列中读取并在单个事务中写入数据库.我使用Atomikos提供XA交易行为.例如,当应用程序突然用kill语句终止时,我看到消息丢失了.我需要使用任何特定的配置吗?队列应该持久吗?当前,队列是非持久性的.我的MQ版本是v7.1.

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配置如下:

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.

谢谢.

推荐答案

如果您使用的客户端是今年5月之前下载的,则必须是扩展事务客户端.截至2012年5月,任何V7.0.1和更高版本的客户端都内置了XA功能.如有疑问,请下载最新版本的WMQ客户端并进行安装.

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.

第二,XA事务管理器必须具有自己的与队列管理器的连接,而与应用程序无关.这样,如果应用程序无法重新启动,它可以连接并协调事务.为此,必须按照信息中心主题 配置符合XA的交易管理器 .

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.

对于它的价值,在WMQ中没有持久队列之类的东西.消息本身是持久的(或不是持久的).有关更多信息,请参见我的有关该主题的博客文章.这是一个非常重要的主题,因为当人们认为队列本身是持久性的时,他们倾向于设计出产生意外结果的解决方案.请阅读博客文章!

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!

这篇关于WebSphere MQ和Atomikos-进程终止时消息丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 08:29