1) First install the messege queue from add windows component from control panal
Control Pannel--> Add or Remove Program-->Add/Remove windows componenets--->
Check the Messege Queue .
2) Create the new website using Microsoft developer studio
3) Add the textbox and labels to aspx page the to queue path and messeges like this
4) Now at .cs file first we import the namespace (System.messeging)
5) At rest of code like this:
protected void Button1_Click(object sender, EventArgs e)
{
MessageQueue mess = new MessageQueue(txtPath.Text);
Message myMessege = new Message(txtSend.Text
mess.Send(myMessege);
Response.Write("Messege Send Successfully!!!");
}
Now we are ready to create messege to messege queue.(Rememeber the path of messege queue is (.\private$\name of messege queue) and also make sure the messege queue should already exist)
Now Next Step is to create the Listner of the messege Queue .
1)Add new web page.
2) At .cs file use the following code:
At page load:
MessageQueue msmq = new MessageQueue(@".\private$\Test");(Name of Private Queue)
Message mess = new Message();
mess.UseDeadLetterQueue = true;
try
{
mess = msmq.Receive(new TimeSpan(0, 0, 30));
Type[] target = new Type[1];
target[0] = typeof(string);
mess.Formatter = new XmlMessageFormatter(target);
Label2.Text = (string)mess.Body;
}
catch (MessageQueueException eReceive)
{
Response.Write(eReceive.MessageQueueErrorCode.ToString());
Label1.Visible = false;
}
}
All the Best .
Happy Coding.