2011-01-24 140 views
3

我在相同的目标中按顺序添加两个JMS消息。这些消息是否会按照我添加它们的相同顺序接收,或者是否有反向排序的机会,也就是说,首先会在目标中先收到哪个消息。JMS队列消息接收订单

我加入到目的地为:

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

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

回答

2

按照同样

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. 

因此,要回答你的问题的消息将在它们上面的信息被发送的顺序接收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. 

。然而,将消息传递到服务器的顺序将受限于诸如消息优先级,持久性/非持久性等限制。