Introduction
Recently, we faced a production issue where our web application was not able to write in our queue. Since all writing over queue is encapsulated in COM based Wrapper class which only returns Boolean in case of success or failure, it led us to hours and hours of investigation which led to nowhere. But the same wrapper class works outside of IIS (Desktop version of the application).
In order to improve investigation, we quickly built a sample web application which inserted a message into defined queue.

The above screen creates appropriate messages in the message queue (see below).

Using the Code
The code is extremely simple to use and by nature, self explanatory.
protected void btnSubmit_OnClick(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
try
{
sb.Append("btnSubmit_OnClick Called" + "<BR/>");
System.Messaging.Message msg = new System.Messaging.Message();
sb.AppendLine("Msg.Label => " + txtLabel.Value + "<BR/>");
msg.Label = txtLabel.Value;
sb.AppendLine("Msg.Body => " + txtareaBody.Value + "<BR/>");
msg.Body = txtareaBody.Value;
sb.AppendLine("Initiating Message Queue => " + txtQueueName.Value + "<BR/>");
MessageQueue mq = new MessageQueue(txtQueueName.Value);
sb.AppendLine("Message Queue Exists?" + "<BR/>");
if (MessageQueue.Exists(mq.Path) == false)
{
sb.AppendLine("Message Queue not exist, aborting operation" + "<BR/>");
}
else
{
sb.AppendLine("Message Queue exist" + "<BR/>");
sb.AppendLine("Initiating send message" + "<BR/>");
mq.Send(msg);
sb.AppendLine("Send Message Success" + "<BR/>");
}
}
catch (Exception ex)
{
sb.Append(ex.ToString() + "<BR/>");
}
outputMessage = sb.ToString();
}
This sample application help us in identifying access issues and leads to resolution.
Points of Interest
This sample application help us in identifying access issues and leads to resolution.
History
- 22nd April, 2019: 1.0: First version