So, my messages weren't being deleted in my MSMQ even though I had set the timeout value in Biztalk to have it delete after 1 minute! What's going on?
I am currently developing an application where Biztalk writes messages to a private MSMQ queue. One thing I have realized is that the Timeout value on the send port is not necessarily the time-to-live for the message once it gets into the MSMQ, but simply the time it takes for the message to hit the MSMQ queue.
I ended up writing a small windows service that ended up being really simple to purge all messages in my queue.
string[] __privatequeues = ConfigurationManager.AppSettings["PrivateQueues"].Split(',');
foreach(string __queueName in __privatequeues)
{
string __queuepath = String.Format(".\\private$\\{0}", __queueName);
if (MessageQueue.Exists(__queuepath))
{
using (MessageQueue __queue = new MessageQueue(__queuepath))
{
__queue.Purge();
}
}
}
I need to figure out how to get syntax highlighting working properly, but I'll do that when I have a bit more time.
Anyways, that code above simply loops through all of the comma delimited queues I have located in my app.config file and purges all messages in each of those queues. I ran this as a scheduled task and now it runs great!
So afterwards, I went into MSMQ and looked at the column Message Quote Size. I was wondering why that kept growing even though my messages were getting purged every so often. Turns out that the MSMQ Message Quota Size refers simply to the amount of bytes in the message payload for all the messages. So nothing really to worry about. If you have one message, it will show you the amount of bytes that one message takes up.
Hopefully this helps someone scratching their head on why there is only one message in the message queue and yet the Message Quota Used is in the 50,000 range!