JMS队列消息接收顺序

发布于 2024-10-13 06:11:48 字数 248 浏览 2 评论 0原文

我按顺序在同一目标中添加两条 JMS 消息。这两条消息的接收顺序是否与我添加它们的顺序相同,或者是否有可能进行相反的排序,即首先检索目的地中首先接收到的消息。

我添加到目的地的方式是:

producer.send(Msg1);
producer.send(Msg2);

Msg1Msg2 将在所有情况下按顺序添加(例如网络故障和延迟等)?

I am adding two JMS messages in the same destination sequentially. Will both of these messages be received in the same order in which I have added them or is there a chance for reverse ordering, that is, which ever the message is received first in the destination will be retrieved first.

I am adding into a destination as:

producer.send(Msg1);
producer.send(Msg2);

Msg1 and Msg2 will be added sequentially in all the cases (like network failures and latency. etc.)?

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

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

发布评论

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

评论(2

三生殊途 2024-10-20 06:11:48

不保证消息排序(且规范未强制要求)和总计JMS 消息排序详细解释了原因。另请参阅 StackOverflow 帖子如何处理消息顺序在 JMS 中?

Message ordering is not guaranteed (and not mandated by the specification) and Total JMS Message ordering explains the details of why. Also see the Stack Overflow post How to handle order of messages in JMS?.

潇烟暮雨 2024-10-20 06:11:48

根据 JMS2 规范

JMS defines that messages sent by a session to a destination must be received
in the order in which they were sent. This defines a partial ordering
constraint on a session’s input message stream.

JMS does not define order of message receipt across destinations or across
a destination’s messages sent from multiple sessions. This aspect of a
session’s input message stream order is timing-dependent. It is not under    
application control.

Although clients loosely view the messages they produce within a session
as forming a serial stream of sent messages, the total ordering of this stream
is not significant. The only ordering that is visible to receiving clients is
the order of messages a session sends to a particular destination.
Several things can affect this order like message priority, 
persistent/non persistent etc.

为了回答您的问题,消息将按照与上述信息一起发送的顺序接收。然而,消息传递到服务器的顺序将受到消息优先级、持久/非持久等限制的约束。

As per JMS2 specs

JMS defines that messages sent by a session to a destination must be received
in the order in which they were sent. This defines a partial ordering
constraint on a session’s input message stream.

JMS does not define order of message receipt across destinations or across
a destination’s messages sent from multiple sessions. This aspect of a
session’s input message stream order is timing-dependent. It is not under    
application control.

Also

Although clients loosely view the messages they produce within a session
as forming a serial stream of sent messages, the total ordering of this stream
is not significant. The only ordering that is visible to receiving clients is
the order of messages a session sends to a particular destination.
Several things can affect this order like message priority, 
persistent/non persistent etc.

So to answer your question messages will be received in the same order they were sent with above information. The order in which messages are delivered to the server however will be constrained by limitations like message priority, persistent/non persistent etc.

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