Microsoft KB Archive/173327
Article ID: 173327
Article Last Modified on 3/9/2000
- Microsoft Message Queue Server 1.0
This article was previously published under Q173327
When messages are sent from the same machine, all of the messages associated with a given transaction are grouped together when read; and that group of messages arrives in the order that the messages are committed. The following pseudo code scenario shows the ordering of the messages:
begin trans1 begin trans2 write trans1.msg1 write trans2.msg1 write trans1.msg2 write trans2.msg2 commit trans2 commit trans1
This results in the following ordering of messages when read from the queue:
trans2.msg1, trans2.msg2, trans1.msg1, trans1.msg2
However, this ordering may be different in some cases, as described below.
The above message ordering is correct as long as all the messages are sent from the same machine.
Consider the following case:
Machine A begin transactiona send a1 to q send a2 to q send a3 to q commit transactiona Machine B begin transactionb send b1 to q send b2 to q send b3 to q commit transactionb
Microsoft Message Queue Server guarantees that all messages from A are ordered and all messages from B are ordered in the queue. But messages from A and B could be interleaved in the queue. For example, the queue could look like this:
q: a1 b1 b2 a2 b3 a3
Microsoft Message Queue Server guarantees the following:
- On the sender machine, if you send multiple messages inside a transaction at commit time, the messages will all be sent (NOTE: the messages will be sent, but not necessarily received), or at abort time none will be sent.
- MSMQ delivers the messages no more than once in the destination queue, and in order.
For example, if you sent three messages with five minutes time to live in a transaction, and commit, MSMQ will begin sending those messages one by one. Because of their time to live, message 1 and 2 might get into the queue, and message 3 may not because it will expire. Every message is autonomous, even if they were sent in the same transaction.
A message will be put into a queue, whenever it reaches the target queue manager. MSMQ does not wait for all the messages sent in the same transaction to reach the queue manager, before putting them all in the queue.
To determine when all messages written in a transaction have been read, an application has to tag all the messages sent in the same transaction, and define whenever the last message is sent/received.
MSMQ SDK Online help
Keywords: kbinfo kbfaq KB173327