JMS队列消息接收顺序

3

我正在依次向同一目的地添加两个JMS消息。这两个消息将按照我添加它们的顺序接收,或者存在反向排序的可能性,也就是说,无论哪个消息先到达目的地,都会先被检索出来。

我的添加方式如下:

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

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

2个回答

6

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

那么,回答你的问题,消息将按照发送顺序接收,并带有以上信息。然而,消息传递到服务器的顺序会受到诸如消息优先级、持久性/非持久性等限制的约束。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接