Here's the scenario:
2 Machines: "Machine A" and "Machine B".
Let's sat that their corresponding IP addresses are 192.168.0.100 (for A) and 192.168.0.200 (for B). Both machines have MSMQ installed on them, on Windows Server 2008.
Machine A
Has the following queue configured: private$\aaa
, transactional.
Has a single consumer for that queue, which wraps every Read
action in an MSMQ transaction, and reads only from the "current" message (that is, no cursor operations are used).
Machine B
Has a single application that sends messages to FormatName:direct=os:192.168.0.100\private$\aaa
. Each Send
message is wrapped in an MSMQ transaction, with (code in C#):
TimeToReachQueue = Message.InfiniteTimeout
and
TimeToBeReceived = Message.InfiniteTimeout
And... the question
Under this scenario and configuration of private$\aaa
, are the messages sent from B to A:
- Delivered once? I mean, do I have to make sure in the consumer application on machine A that the "current" message is actually "new" (that is, was not processed before)? Or does the MSMQ itself take care for that matter?开发者_如何学编程 I know it sounds a bit silly, since it's a queue, right?! But I couldn't find a concrete reference claiming that the messages are in order. I've seen such a claim, but not from Microsoft official resource.
- In-order? I mean, is it possible that a message
M1
cannot be sent from B to A, because of network problems, and then, perhaps, the network is back to normal, and the following message,M2
, is successfully sent to machine A?
Thanks a lot!
Delivered Once is guaranteed, but keep in mind that you have a transactional queue, so if message processing fails the first time, then it'll be delivered again until it either succeeds or gets moved to a poisoned message queue. Therefore "Delivered Once" is only guaranteed within that context, and if the other resources you manipulate are also transactional and participate in the distributed transaction then you should be safe.
Messages are "sent together, in the order they were sent, or not at all". See MSMQ Tips
精彩评论