Message message = mq.Peek
if (message != null)
{
message.Formatter = new XmlMessageFormatter (new string[]{ "System.String,mscorlib"});
string messageBody = message.Body.ToString ();
if (messageBody != null)
{
if (messageBody.Contains ("ErrorFile"))
{
using (MessageQueueTransaction transaction =
new MessageQueueTransaction ())
{
if (mq.Transactional)
{
transaction.Begin ();
message = mq.Receive ();
//message = mq.ReceiveById();
transaction.Commit ();
}
}
}
}
}
I am trying to read the message from MSMQ and if I found specific matching message I am trying to remove from queue, but facing issue is it only removing body from the message and leaving behind empty message in MSMQ.
instead using Peek() in that place if I use Receive() method I can able to remove message from queue but it will remove all messages irrespective of any matches but I don’t what that.
I need a solution only to remove matching specific message from the queue permanently without leaving any empty message in the queue.
Vishal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.