You can retrieve lists of the queues on your Message Queuing network and the messages they contain by using any of a variety of retrieval methods available in the MessageQueue class. You might retrieve lists of queues and messages if you wanted to perform administrative tasks, generate reports about queue contents, or search through the contents of a queue for messages that meet specific criteria.
There are two main ways you can retrieve both messages and message queues: you can retrieve a static snapshot of the messages or queues on the network, or you can iterate through messages and queues using an enumerator. Retrieving a static list of queues or messages is faster than retrieving an enumeration but doesn't give you as much accuracy in or control over the resulting set of information. You might use a static snapshot of retrieval if you need to perform an administrative task on all public queues in your network.
Enumerators give you finer control over how you interact with the retrieved results. Using an enumerator, you can locate a queue or message that meets certain criteria, instead of evaluating each and every item in the returned collection. For example, you might use an enumerator if you want to review the contents of a queue and work with only those messages for which a particular property has been set to true.
You can retrieve information about message queues in the following ways:
You can also use the Exists method to determine whether a queue you are interested in exists. The Exists method searches for a specific queue by a path you define.
For instructions on retrieving lists of message queues, see Retrieving Queues.
When you retrieve messages in an array or enumerator, you do not actually pull those messages off the queue as you do when you read or receive messages. Instead, you retrieve information about the items in the queue, while the actual messages remain available to the users who were intended to receive them.
You can retrieve messages in the following ways:
For instructions on retrieving lists of messages, see Retrieving Messages.
After you create an enumeration of messages or queues, the enumerator is conceptually positioned before the first item of the enumeration. You can call the GetNext method to move to the first item in the list, and to move through subsequent items. You can also use the Current method to return the item you're currently positioned on in the enumeration.