Share via


Messages

Applies To: Windows Server 2008

Messages

In the context of Message Queuing, messages consist of a body and a set of properties. Message bodies can contain text or any form of binary information, and can be encrypted. Most message properties are specified programmatically by Message Queuing applications. Some properties, such as the sender's security ID (SID) and the message ID, are specified by Message Queuing. Message properties cannot be encrypted. A message, including the body and all specified properties, can be no larger than 4 megabytes (MB) in size.

A message body can contain text or binary information. If a message body contains text information, this information is displayed. If a message body contains binary information, hexadecimal data is displayed along with its text translation. Message bodies can be viewed on the Body dialog box for the message.

To retrieve messages from a queue, you must first be granted the Receive Messages permission for the queue. It is not sufficient to have the Read permission granted for the queue. For information about how to set permissions for queues, see Access Control for Message Queuing.

Message lookup

Applications can be written to peek at or retrieve a specific message without navigating through the queue to find the message. This functionality is based on a 64-bit lookup identifier that is assigned to each message when it is placed in a destination queue. The lookup identifier of a message is unique within the queue and is always greater than the lookup identifier of the preceding message and less than the lookup identifier of the next message. Note that this functionality is designed to help you look at specific messages you have received. It is not a random search mechanism.

Both messages sent by applications and messages sent by Message Queuing have a lookup identifier. The local queue manager generates the lookup identifier and sets the lookup identifier properties of the message (PROPID_M_LOOKUPID and MSMQMessage.LookupId) whenever it places a message in a queue. Message Queuing generates a lookup identifier for messages placed in user- and application-generated queues, such as destination queues, administration queues, response queues, and report queues, as well as for copies of messages placed in system-generated journals, dead-letter queues, and connector queues. If a message is sent to several destination queues, or if a copy of a message is stored in a computer journal or queue journal, each copy of the message will be assigned its own lookup identifier when it is placed in its respective queue.

Message Queuing has an API function and methods of the MSMQQueue object that enable applications to perform the following tasks programmatically without using cursors:

  • Peeking at the first message in the queue.

  • Peeking at the message preceding the message specified by the message lookup identifier supplied.

  • Peeking at the message specified by the message lookup identifier supplied.

  • Peeking at the message immediately following the message specified by the message lookup identifier supplied.

  • Peeking at the last message in the queue.

  • Retrieving the first message in the queue.

  • Retrieving the message preceding the message specified by the message lookup identifier supplied.

  • Retrieving the message specified by the message lookup identifier supplied.

  • Retrieving the message immediately following the message specified by the message lookup identifier supplied.

  • Retrieving the last message in the queue.

When API function calls are made to peek at or retrieve messages, messages can be processed asynchronously, synchronously, or within a transaction. However, the method calls process the messages synchronously.

A receiving application can use the lookup identifier of a message to go directly to that message and then continue navigating the queue from that point toward the front or the end of the queue. Lookup identifiers differ from cursors in this respect. When cursors are used, the application must start at the front of the queue and navigate towards the end of the queue.

Purging messages

You can purge all messages in any queue, including outgoing queues. The only exception to this is system queues. Note that you cannot purge individual messages in a queue. For instructions on purging all messages in a queue, see Purge All Messages in a Queue.

In This Section