如何使用MDB从队列中按顺序读取消息?

发布于 2024-10-05 21:15:43 字数 81 浏览 6 评论 0原文

我有一个监听 WebSphere MQ 的 MDB。它不会按照队列接收的顺序拾取消息。我怎样才能让它按顺序读取?是否可以?我不应该使用 MDB 吗?

I have a MDB which listens to WebSphere MQ. It does not picks up the messages in the order that has been received by the Queue. How can i make it read it in that order? Is it possible? Should i not use a MDB.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

以为你会在 2024-10-12 21:15:43

一般来说,WMQ 按照消息接收的顺序传送消息。但是,有几件事可能会影响...

  1. 如果队列设置为优先级而不是 FIFO 传送,并且消息以不同的优先级到达,则它们将“无序”传送。
  2. 区分已生产订单和已交付订单。如果消息是在远程 QMgr 上生成的,并且有多个路径到达本地 QMgr,则消息可能会乱序到达。
  3. 持久性差异 - 如果消息在远程 QMgr 上生成并且具有不同的持久性,则非持久性消息可能比持久性消息更快到达,尤其是在设置了通道 NPMSPEED(FAST) 的情况下。
  4. 多个读取器/写入器 - 对序列的任何依赖都意味着单个生产者通过单个路径发送到单个消费者。生产者、消费者或它们之间的路径中的任何冗余都可能导致消息传递不按顺序进行。
  5. 同步点 - 为了保持顺序,所有消息必须在同步点下写入和使用,否则所有消息必须在同步点之外写入和使用。
  6. 选择器 - 这些专门用于按照队列中所有消息的上下文无序地传递消息。
  7. 消息组 - 分组消息的检索通常要等到整个组都出现为止。如果组交错,则消息将不按顺序传递。
  8. DLQ - 如果目标队列已满,消息可能会传递到 DLQ。当目标队列被清空时,消息开始返回那里。当队列接近容量时,消息可以在目标队列和 DLQ 之间交替。

因此,当 MDB 接收无序消息时,这些因素中的任何一个或什至其中几个因素的组合都可能是原因。要么消除对消息顺序的依赖(最佳选择),要么返回设计并协调所有可能导致乱序处理的因素。

In general, WMQ delivers messages in the order that they were received. However, several things can impact that...

  1. If the queue is set to priority instead of FIFO delivery and messages arrive in different priorities, they will be delivered "out of order".
  2. Distinguish between order produced and order delivered. If the messages are produced on a remote QMgr and there are multiple paths to the local QMgr, messages may arrive out of order.
  3. Difference in persistence - if messages are produced on a remote QMgr and are of different persistences, the non-persistent messages may arrive faster than the persistent ones, especially with channel NPMSPEED(FAST) set.
  4. Multiple readers/writers - Any dependency on sequence implies a single producer sending to a single consumer over a single path. Any redundancy in producers, consumers or paths between them can result in messages delivered out of sequence.
  5. Syncpoint - To preserve sequence, ALL messages must be written and consumed under syncpoint or else ALL must be written and consumed outside of syncpoint.
  6. Selectors - These specifically are intended to deliver messages out of order with respect to the context of all messages in the queue.
  7. Message groups - Retrieval of grouped messages typically waits until the entire group is present. If groups are interleaved, messages are delivered out of sequence.
  8. DLQ - if the target queue fills, messages may be delivered to the DLQ. As the target queue is drained, messages start going back there. With a queue near capacity, messages can alternate between the target queue and DLQ.

So when an MDB is receiving messages out of order any of these things, or even several of them in combination, may be at cause. Either eliminate the dependency on message sequence (best choice) or else go back over the design and reconcile all the factors that may lead to out-of-sequence processing.

日记撕了你也走了 2024-10-12 21:15:43

为了添加到 T.Rob 的列表,MDB 使用应用程序服务器 WorkManager 来安排消息传递,因此消息顺序也取决于 WorkManager 启动工作项的顺序。这不在 WMQ 的控制范围内。如果将 MDB ServerSessionPool 深度限制为 1,则该限制将被删除,因为只会有一个运行中的工作实例,但代价是降低最大吞吐量。

如果您在 WebSphere 应用程序服务器中运行,那么带有 ListenerPorts 的非 ASF 模式可以保留消息顺序,但会受到一些事务/回退警告的影响。这里有一个支持技术说明:

http://www-01.ibm.com /support/docview.wss?uid=swg21446463

To add to T.Rob's list, MDBs use the application server WorkManager to schedule message delivery, so message order is also dependent on the order in which the WorkManager starts Work items. This is outside the control of WMQ. If you limit the MDB ServerSessionPool depth to one, then this limit is removed as there will only ever be one in-flight Work instance, but at the cost of reducing maximum throughput.

If you're running in WebSphere application server, then non-ASF mode with ListenerPorts can preserve message order subject to some transactional/backout caveats. There's a support technote here:

http://www-01.ibm.com/support/docview.wss?uid=swg21446463

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文