Just another tech site

MSMQ : Microsoft Message Queuing


Queues are an inter process communication mechanisme used by application to exchange information.

a little bit of history
– Version 1.0 (May 1997). Supports Windows 95, Windows NT 4.0 SP 3, Windows 98 and Windows Me.
– Version 2.0, included with Windows 2000.
– Version 3.0, included with Windows XP (Professional, not Home Edition) and Windows Server 2003.
– Version 4.0, part of Windows Vista and Windows Server 2008.
– Version 5.0, part of Windows 7 and Windows Server 2008 R2.

A code sample

Step1 Create the queue

      //creates an instance MessageQueue, which points 
      //to the already existing MyQueue
      mq = new System.Messaging.MessageQueue(@".\Private$\MyQueue");
      //creates a new private queue called MyQueue 
      mq = MessageQueue.Create(@".\Private$\MyQueue");

Step2 Send a message to the queue

System.Messaging.Message mm = new System.Messaging.Message();
mm.Body = txtMsg.Text;
mm.Label = "Msg" + j.ToString();

Step3 Receive a message from a queue

      mes = mq.Receive(new TimeSpan(0, 0, 3));
      mes.Formatter = new XmlMessageFormatter(
        new String[] {"System.String,mscorlib"});
      m = mes.Body.ToString();
      m = "No Message";

The queue message are serialized and deserialized. in the example XmlMessageFormatter has been used


[1] http://en.wikipedia.org/wiki/Microsoft_Message_Queuing


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Tag Cloud

%d bloggers like this: