Using the System.Messaging Namespace

Before writing messaging applications, let's take a quick look at the key classes provided by the System.Messaging namespace.

The MessageQueue class is the most important class in the System.Messaging namespace. This class represents a messaging queue in a messaging queuing server. This class provides members to send messages to and receive messages from MSMQ. The Create and Delete static methods of this class create and delete message queues, respectively. This class also provides methods to retrieve and filter private and public queues available on the server.

The Message class is another important class of the System.Messaging namespace. The Message object represents a message in message queuing. This class provides access to messages of a message queue. It provides properties that you can use to read a message body, label, priority, posting time, sender, authentication mode, and so on.

The MessageEnumerator class represents an enumeration, which provides a forward-only cursor through messages in a message queue, which you can use to navigate through from the first message to the last in a message queue. An enumerator returns information about the message at the current cursor position. It doesn't remove the message from the queue.

The MessagePropertyFilter class controls and filters messages from a message queue. The MessageReadPropertyFilter property of MessageQueue uses the MessagePropertyFilter object.

The MessageQueueEnumerator class provides a forward-only cursor that you can use to enumerate (loop) through the messages in a server.

The MessageQueueTransaction class represents a transaction in message queuing. A complete messaging transaction contains a successful send and successful receive. The MessageQueueTransaction can commit or roll back transactions. Messages sent to transactional queues are removed if a transaction is rolled back, and messages received from transactional queues are returned to the queue if the transaction is rolled back.

The Trustee class represents a user or a group account with a set of access rights that is trying to access a messaging item. The AccessControlEntry class allows, denies, or revokes access rights to a trustee.

The AccessControlList class represents a loss of access control entries that specify access rights for trustees. It's a collection of AccessControlEntry objects.

The System.Messaging namespace also provides some formatting-related classes. These classes are ActiveXMessengerFormatter, BinaryMessageFormatter, and XmlMessageFormatter.

Messaging in .NET is compatible with previous versions of MSMQ. ActiveXMessengerFormatter provides interoperability functionality, so you can use MSMQ ActiveX controls in the .NET Framework.

The BinaryMessageFormatter class serializes and deserializes objects to or from the body of a message in a binary format.

XML is the default format used by MSMQ and messaging services. XmlMessageFormatter is responsible for serializing and deserializing objects to or from the body of a message in Extensible Markup Language (XML) format using XML Schema Definition (XSD).

Finally, the System.Messaging namespace also provides one messaging-related exception handling class: MessageQueueException. This class represents the exception that is thrown if an MSMQ internal error occurs.

Applied ADO. NET(c) Building Data-Driven Solutions
Applied ADO.NET: Building Data-Driven Solutions
ISBN: 1590590732
EAN: 2147483647
Year: 2006
Pages: 214 © 2008-2017.
If you may any questions please contact us: