Share via


Queue and Message Collections 

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 does not 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.

Message Queues Retrieval

You can retrieve information about message queues in the following ways:

  • You can retrieve a static array of all of the public or private queues on the network.

  • You can retrieve a static subset of all the public queues on the network by specifying certain criteria such as the date and time the queue was created or modified, or by specifying a category, label, or computer by which to retrieve queues.

  • You can iterate queues on the network using an enumerator, or you can iterate through a subset of all the queues on the network by specifying criteria such as computer name, date and time created, and category.

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 How to: Retrieve Queues.

Message Retrieval

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:

  • You can retrieve a static array of all the messages in a queue.

  • You can iterate messages in a queue using an enumerator.

For instructions on retrieving lists of messages, see How to: Retrieve Messages.

Working with Items in an Enumerator

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 MoveNext 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 are currently positioned on in the enumeration.

See Also

Tasks

How to: Retrieve Queues
How to: Retrieve Messages