The Message Class

Team Fly 

Page 349

TABLE 14.1: THE PROPERTIES OF THE MESSAGEQUEUECRITERIA CLASS

FILTER NAME

DESCRIPTION

Category

The category of the desired queue(s). A queue's category need not be unique.

CreatedAfter

A date that filters out the queues that were created before the specified date.

CreatedBefore

A date that filters out the queues that were created after the specified date.

Label

A string that specifies the queue's label. MachineName The computer name on which the desired queue(s) reside.

ModifiedAfter

A date that filters out the queues that have not been modified after the specified date.

ModifiedBefore

A date that filters out the queues that have not been modified before the specified date.

Another method to retrieve the queues on a computer is to use the MessageQueueEnumerator class. The GetMessageQueueEnumerator method of the MessageQueue class returns a MessageueueEnumerator object, which you can use to iterate through all public queues in the network. This is a typical enumerator that exposes the MoveNext method, which moves to the next queue, and the Current property, which references the current queue

The MessageQueue classes expose members to send messages as well as retrieve messages from queues. These methods make use of the Message class, which represents queue messages. In the following section we'll discuss the Message class and then look at the methods of the MessageQueue class for manipulating messages.

The Message Class

The other major class of the Messaging namespace is the Message class, which represents MSMQ messages. You've seen how to send simple messages with the Send method of the MessageQueue class, but applications exchange information in the form of objects, not strings. Moreover, the simple form of the Send method we used in our earlier example doesn't allow you to set the properties of the message: You can't assign a label to the message (a string that describes the message while it resides in the queue), nor can you change the message's priority. You should always create Message objects and pass them to the Send method, even if these objects are strings.

The Message class exposes only properties and no methods. The purpose of this class is to enable us to manipulate the properties of the messages before sending them to a queue, or read the properties of messages retrieved from a queue. To send a Message object you must create an instance of the Message class, populate its properties, and then pass it as argument to the Send method of the MessageQueue class. The Message class exposes two types of properties: read-only properties designed to work with incoming messages and read/write properties designed to work with outgoing messages. To read a message off a queue, you must create a new instance of the Message class and assign to this object the value returned by one of the methods that reads messages from a queue.

Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net