In the previous blog post we went over some of the MSMQ bascis. In this blog post we'll touch on how to monitor, troubleshoot and backup MSMQ.

I've been using NServiceBus with the MSMQ transport for a while now and have faced some issues. Unfortunately, information about MSMQ is pretty scarce and sometimes outdated. This blog post contains links to resources that I've found useful for understanding some of the best practices around MSMQ administration.

Monitoring

Events

MSMQ logs informational, warning and error events under the Application Log. When accessing an object fails or succeeds, it also adds an audit entry in the Security Log. All message queuing events contain the "MSMQ" text in the Source column.

If you have enabled End-to-End tracing, you can find the trace events in Application and Services Logs/Microsoft/Windows/MSMQ/End2End.

Dead-Letter Queues

When a message expires, the queue manager puts it in one of the dead letter queues. This ensures that messages are not lost. A message expires when one of its timers (Time-To-Reach-Queue or Time-To-Be-Received) expire. There are two dead-letter queues, one for non-transactional messages and one for transactional messages. In order to keep track of expired messages, you should monitor the dead-letter queues.

External Transactions

MSMQ can take part in external transactions. You can monitor these transactions by using the Distributed Transaction Coordinator Transaction Statistics and Transaction List views. Since internal transactions don't go through MSDTC, these can't be monitored using this approach.

Disk space depends on the throughput of messages that flow through your system, their size, and the amount of time it takes to recover from a failure (and start processing messages again). You don't want to start losing messages because you can't store them on disk. You should monitor disk space using performance counters. If there is not enough disk space, you can either increase the MSMQ computer quota and maybe change the MSMQ storage location.

If you want to find out more about MSMQ troubleshooting, check out these links:

As usual, Particular Software provide top notch documentation. Even if you're not using NServiceBus, their MSMQ troubleshoot guide is a must read when facing MSMQ related issues. Be sure to click on the Useful Links section for further reading.

Backup and Restore

MSMQ comes with a command line utility - mqbkup - for backup and restore. Using this tool you can backup storage files, log files, transaction files, and Registry settings. I've also heard that QueueExplorer is a good tool for managing MSMQ, although I haven't tried it yet.

Conclusion

In my limited experience with MSMQ, I have ran into a couple of issues. Most of them were caused by the fact that I didn't monitor it well enough or I didn't understand how it works under the hood. In this blog post I've summarized some of the best practices around MSMQ monitoring and troubleshooting. I'll probably update this post whenever I learn something new about MSMQ.