Microsoft Message Queuing (MSMQ) has been around a long time and, from my experience, is very stable. I have used the independent client approach with private queues in a variety of systems with excellent results. It is available in all versions of Windows Server and Windows 2000, Windows XP, Windows Vista, and Windows 7 (at least).
The purpose of Message Queuing is to send and receive data to/from a queue. Message Queuing is a really slick way to implement inter-process communication. More importantly to some, it provides a means for guaranteed delivery – even when the receiving process is shut down.
In basic terms, a Message Queuing client can create/modify local queues and send/receive messages entirely by itself to any other client or locally. There is often confusion about the capabilities of an independent client.
The Microsoft .Net Framework provides Message Queuing functionality via the System.Messaging namespace. It doesn’t matter whether you are using VB.Net, C#.Net, or vbScript – Message Queuing is available to you.
The System.Messaging.Message Label property is of type string. The Body is of type object. The body contain nearly anything desired.
In the most simple form, a message can be sent using the following example:
outboundMessage.Label = "LabelText"
outboundMessage.Body = "BodyText"
Dim outboundMessageQueue As New MessageQueue(".\private$\QueueName")
outboundMessageQueue.Send(outboundMessage)
outboundMessageQueue.Close()
Pretty simple stuff. However; a tremendous amount of functionality is ignored in the above.
Guaranteed Message Delivery
The sender of a message may set the Message.Recoverable property to guarantee delivery. This forces MSMQ to persist the message to disk locally (in an outbound queue) before sending to the destination queue. The outbound queue message is deleted only after the message has been delivered to the destination. In this way, the destination computer can be offline when the message is sent, the local computer could be restarted while the message is being sent, or network communication severed during transmission and the message will be delivered when the destination computer becomes available.
Message Timeout
The Message.TimeToBeReceived TimeSpan property can be set to automatically eliminate messages if they are not delivered after some period of time. I usually set this value when a message is informational – messages that are desired but not worth piling up in the queue and creating a backlog of messages that must later be processed.
Message Priority
All messages in a queue are processed in priority order. By default, messages are sent as a “normal” priority. The sender may set the Message.Priority property as desired to control this behavior. I typically set informational type message to a lower System.Messaging.MessagePriority so these messages do not slow the processing of more important messages – vice-versa is also done.
For more message queuing implementation details try these additional posts:
Leave a Reply