0
Posted on 5:42 AM by Softminer and filed under , ,

From Control panel -> Turn windows features on or off its possible to install windows Message Queuing
http://technet.microsoft.com/en-us/library/cc730960.aspx

To Send and recieve message using c# first you have to create a message queue:
http://www.codeproject.com/Articles/5830/Using-MSMQ-from-C

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


To Send message

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


and to recieve message

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


to See messages in windows open Computer Management and from Service applications -> Message Queuing

0
Responses to ... Sending and recieving message using C# in Windows Message Queue