如何处理JMS中的消息顺序? [英] How to handle order of messages in JMS?

查看:211
本文介绍了如何处理JMS中的消息顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在审查用Java编写的客户端 - 服务器应用程序。服务器接收JMS消息并处理它们,但消息可能以意外的顺序出现,并且取消可以在订单消息之前到达。你是如何处理这种情况的?你是在mdb中做的吗?

I am reviewing a client-server application written in Java. The server receives JMS messages and processes them but the messages can come in an unexpected order, and a cancel can arrive before an order message. How do you handle such a case? Do you do it in the mdb?

这种情况有哪些策略或模式?

What are some strategies or patterns for this kind of scenario?

推荐答案

到目前为止,我知道,这被称为无序传递,并且是JMS系统的服务质量(QoS)属性的一部分。我不认为它是JMS规范的一部分,但有些提供商可能支持它。这将取决于您使用的特定JMS实现。

So far I know, this is refereed to as "out-of-order" delivery and is part of the quality of service (QoS) attributes of the JMS system. I don't think it's part of the JMS specification, but some provider support it maybe. That will depend on the particular JMS implementation you use.

但请注意,JMS旨在以分发的方式将消息分发给几个消费者负荷。如果必须以有序的方式传递消息,则这是不可能的 - 它基本上导致消息传递的序列化,并且消息不能同时处理。

Note however that JMS is meant to distribute messages to several consumers in a way to distribute the load. If message have to be delivered in an ordered fashion this is not possible -- it basically lead to serialization of the message delivery and message could not be processed concurrently.

维基百科说它比我:


JMS队列
包含已发送邮件的暂存区域,并且是
等待阅读。请注意,
与名称队列
建议的内容相反,消息不必是在发送的订单中交付的
。如果
消息驱动的bean池包含的
比一个实例多,那么消息可以是
并发处理,因此后来的消息比
更快地处理
较早的。
JMS队列仅保证每个$​​ b $ b消息只处理一次。

JMS queue A staging area that contains messages that have been sent and are waiting to be read. Note that, contrary to what the name queue suggests, messages don't have to be delivered in the order sent. If the message driven bean pool contains more than one instance then messages can be processed concurrently and thus it is possible that a later message is processed sooner than an earlier one. A JMS queue guarantees only that each message is processed only once.

带外取消那么使用JMS就不容易实现请求。两个想法:

Out-of-band cancel request is not easy to achieve with JMS then. Two ideas:


  • 存储与数据库中每条消息对应的票证,可以轻松取消消息。邮件传递时,MDB会检查相应的票证是否仍然有效。如果是,则继续进行,如果没有,则删除该消息。

  • 尝试将MDB池大小设置为1。也许在这种情况下,将订购交货。更改池大小是应用程序。特定于服务器,但大多数都支持每个bean池大小。

否则,可能看一下邮件存储模式。无论如何,值得查看 EAI 网站。

Otherwise, have maybe a look at the message store pattern. It's anyway worth checking the EAI website.

这篇关于如何处理JMS中的消息顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆