繁体   English   中英

JMS队列消息接收顺序

[英]JMS queue message receive order

我按顺序在同一目的地添加两条JMS消息。 这两个消息是否会按照我添加它们的顺序接收,或者是否有可能进行反向排序,也就是说,首先在目的地中首先接收消息。

我正在添加到目的地:

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

在所有情况下(如网络故障和延迟等),将依次添加Msg1Msg2

不保证消息排序(并且不是规范要求)和Total JMS消息排序解释了原因的详细信息。 另请参阅Stack Overflow post 如何处理JMS中的消息顺序?

根据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.

因此,要回答您的问题,将按照与上述信息一起发送的相同顺序接收消息。 但是,消息传递到服务器的顺序将受到消息优先级,持久性/非持久性等限制的约束。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM