Spring Batch - Not all records are being processed from MQ retrieval

时间秒杀一切 提交于 2019-12-05 11:44:48

See http://activemq.apache.org/jmstemplate-gotchas.html .

There are issues using the JMSTemplate. I only ran into these issues when I upgraded my hardware and suddenly exposed a pre-existing race condition.

The short form is that by design and intent the JMS Template opens and closes the connection on every invocaton. It will not see messages older than its creation. In high volume and/or high throughput scenarios, it will fail to read some messages.

As a rule, MQ will NOT lose messages when properly configured. The question then is what does "properly configured" look like?

Generally, lost messages are caused by non-persistence or non-transactional GETs.

If non-persistent messages are traversing QMgr-to-QMgr channels and NPMSPEED(FAST) is set then MQ will not log errors if they are lost. That is what those options are intended to be used for so no error is expected.

Fix: Set NPMSPEED(NORMAL) on the QMgr-to-QMgr channel or make the messages persistent.

If the client is getting messages outside of syncpoint, messages can be lost. This is nothing to do with MQ specifically, it's just how messaging in general works. If you tell MQ to get a message destructively off the queue and it cannot deliver that message to the remote application then the only way for MQ to roll it back is if the message was retrieved under syncpoint.

Fix: Use a transacted session.

There are some additional notes, born out of experience.

  • Everyone swears message persistence is set to what they think it is. But when I stop the application and inspect the messages manually it very often is not what is expected. It's easy to verify so don't assume.
  • If a message is rolled back on the queue, it won't happen until MQ or TCP times out the orphan channel This can be up to 2 hours so tune the channel parms and TCP Keepalive to reduce that.
  • Check MQ's error logs (the ones at the QMgr not the client) to look for messages about transactions rolling back.
  • If you still cannot determine where the messages are going, try tracing with SupportPac MA0W. This trace runs as an exit and it is extremely configurable. You can trace all GET operations on a single queue and only that queue. The output is in human-readable form.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!