Share via


Reading Incoming Messages

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

When the Message Queuing Triggers service is running, the service reads each message as it arrives at the queue. The service can peek at the message and leave it in the queue or retrieve the message from the queue (retrieving the message is introduced in MSMQ 3.0). The Message Queuing Triggers service does not limit access to the messages (it is possible for other Message Queuing applications to remove messages before the trigger service can read a message in the queue).

To read the messages in the queue the service starts at the front of the queue and reads all the messages in the queue. After checking all the existing messages, the service waits at the end of the queue for a new message. (If the service is stopped and restarted, it will read all messages in the queue again.)

When all the messages sent to the queue have the same priority, new messages are always placed at the end of the queue. After reading all the existing messages in the queue, the Message Queuing Triggers service will fire the trigger each time a new message arrives at the end of the queue. The illustration below shows a queue with four messages. The Message Queuing Triggers service reads msg1, msg2, msg3, and msg4, then continues to read messages as they arrive at the end of the queue.

<No Change>

When messages with different priorities are sent to the queue, new message can be placed anywhere in the queue. This means that when a higher priority message is placed somewhere in the queue, the Message Queuing Triggers service reads the new message wherever it is placed in the queue, then continues to read all the lower priority messages that follow the new message in the queue.

<No Change>

In the preceding illustration, the Message Queuing Triggers service makes one pass through the queue peeking at messages msg1, msg2, msg3, and msg4. Then when msg5 arrives at the queue, a new priority 1 message, it is placed between msg2 and msg3. The service goes back and peeks at msg5, then continues to peek at msg3, and msg4 again.

Note

In this case, the trigger is tested twice for messages msg3 and twice for msg4.

More Information

For information on See
The components of Message Queuing triggers Trigger Components
The two types of triggers supported by the Message Queuing Triggers service Serialized and Nonserialized Triggers