In MSMQ, queues are temporary storage locations for different types of messages. Queues can be logically divided into two groups: application queues and system queues. Application queues are created by applications. System queues are created by MSMQ.
Application queues can also be created using the Computer Management MMC snap-in.
Figure 3.3 shows the different types of queues in the Message Queuing services in the Computer Management snap-in.
If the Message Queuing service is not started yet for some reason, you cannot see it under the Services and Applications node in the Computer Management snap-in. You can manually start the Message Queuing service by using the Component Services snap-in. From Services, locate and right-click the Message Queuing service; then select Start (as shown in Figure 3.4).
In Figure 3.3, you may have noticed another type of queue: the outgoing queue. Those queues are used for offline operations in which directory service is not available. When MSMQ on a client machine is configured for offline use, it is called an independent client. When MSMQ on a client machine is configured for real-time access support, it is called a dependent client.
Application queues include message queues, administration queues, response queues, and report queues. These queues are created by applications.
Message queues allow applications to exchange data through messages. Applications can send messages to and receive them from message queues. Message queues can be either public or private. Figure 3.5 shows an example of a message queue called TestQueue that is created as a private queue.
When you create a queue from an application, it is always displayed in lowercase under Message Queuing in the Computer Management snap-in. However, the names in MSMQ are case sensitive, so be extremely careful in your code when you refer to a queue. For example, if you create a queue called MyQueue, it shows up in MSMQ as myqueue. In your code, however, you still need to access this queue by using MyQueue. You get an error if you refer it as myqueue.
Administration queues, which are specified by the sending application, store system-generated acknowledgment messages sent by MSMQ. If you specify the administration queue when you send a message, MSMQ generates an acknowledgment message and sends it to the administration queue specified, indicating whether the original message was successfully sent (see Figure 3.6).
Response queues are specified by the sending application and used by the receiving application to send response messages back to the sending application (see Figure 3.7).
Report queues track the progress of messages as they move through the enterprise. When the sending application enables tracking and specifies a report queue, MSMQ sends report messages to the report queue. A report message is a system message that is generated each time an application message passes through an MSMQ routing server.
System queues are created either by MSMQ or the MSMQ administrator. System queues contain journal queues and dead-letter queues. Whenever an application queue is created, MSMQ automatically create a journal to track the messages that are removed from the queue. Dead-letter queues store messages that could not be delivered. MSMQ provides two dead-letter queues for each computer: one for nontransactional messages and the other for transactional messages. Figure 3.8 shows system queues.
MSMQ messages are data exchanged between applications. Messages can be generated by MSMQ applications or by MSMQ itself. This chapter addresses only application-generated messages and some of their important properties.
For each message, MSMQ generates and assigns a message identifier. The identifier, or ID, of a message is unique on the computer where the message resides and can be used along with other message properties to identify a message. Figure 3.9 shows the property page of a message with its message identifier highlighted.
A message identifier is composed of the machine GUID of the computer that sent the message and an identifier that is unique to the computer. For example, in Figure 3.9, the message identifier is
The Label property of a message is used to describe the message, much like the subject of an email. The Label of the message in Figure 3.9 is Testing.
Unlike an email message, however, the Body property of a message is not limited to string data types. The body of a message is a variant data type. It can be literally any data type, including string, date, numeric, currency, or array of bytes. The body of a message can be a persistent object such as an Excel spreadsheet or even an ADO recordset.
MSMQ journaling allows you to keep track of messages. The two types of MSMQ journaling are source journaling and target journaling. Source journaling tracks messages sent by a computer, whereas target journaling tracks messages removed from a queue.