How Can I View MSMQ Messages and Queues?

I’m working with NServiceBus to send messages to and from different parts of my application. NServiceBus is a mature tool that sits on top of MSMQ and provides a great developer experience for working with a number of different scenarios. One thing that’s challenging when working with queues is figuring out where a message went when it doesn’t show up at the other end of the message bus. Where did things go wrong? How can I see the messages in the queue for MSMQ? Is the queue set up and working?

It turns out that there is built-in support for viewing details of MSMQ baked into the MMC snap-in, though it’s not immediately obvious where to find it. It’s actually under Computer Management > Services and Applications > Message Queuing. Once you get that far, you’ll see a listing of Outgoing Queues, Private Queues, System Queues, and Triggers. You most likely are interested in Private Queues. Here’s a listing of my Private Queues on my dev machine at the moment:

image

If you want to look at a particular message (that no application has picked up), you can drill down into the queue and inspect the Queue messages. Double-clicking on one will show you details of its contents:

image

Of course, once the message is picked up off the queue, it’s no longer there for you to inspect, but NServiceBus and other frameworks provide support for Journal messages, or you could always log things to a queue that nothing is subscribed to, which would let you see the messages here any time you needed to do so.

Using a message bus in your application(s) can have huge benefits in terms of scalability and keeping your applications decoupled from one another. MSMQ is one of the obvious choices on the Microsoft Windows platform (Azure Queues are another one to consider), and NServiceBus makes working with MSMQ from .NET relatively straightforward, once you learn the basics of what you need to do.

By way of reference, here is the NServiceBus configuration responsible for 3 of the queues shown above (datapumpoutgoinginputqueue, error, mainqueue):

 

The names are mine and are likely to change. This is all the configuration that was required for my web application to be able to start sending messages to a separate process (currently on the same machine, but that’s going to change once deployed). Like I said, pretty straightforward.

  • John Breakwell

    Just a quick comment. If you do journal the messages (using the Journal queue (automatically) or a custom one (in code)) you need to purge the queue regularly to ensure the server does not eventually run out of resources.

    I would prefer to recommend journaling message contents to a database.

    Cheers

    John Breakwell

  • Bill Brown

    Could you elaborate on your statement that "[u]sing a message bus in your application(s) can have huge benefits in terms of scalability and keeping your applications decoupled from one another?"

    I’m designing an MSMQ-based application and I just can’t see the value in a message bus. I’m using private queues and I’m never going to switch from MSMQ to ActiveMQ. I’m not doing anything complicated and putting an abstraction layer between my abstraction layer and System.Messaging seems fruitless.

    But it seems like there must be something there for this plethora of message bus frameworks to exist.

  • ssmith

    @Bill,

    A great presentation that calls out some of the architectural benefits of using queues and the CQRS pattern can be found here: http://www.msteched.com/…/ARC302

    For my own applications, being able to simply drop off messages on my local machine is a much faster operation than having to call a sproc on a remote sql machine. Since I need the call to happen, but my response to the user request doesn’t depend on its results, this is an ideal scenario to use a message bus. Your scenario may or may not benefit from this approach – it depends on your application’s needs.

  • Bill Brown

    Thanks for your reply. I understand the benefit of using queues: I am working on one for my application to offload some stats tracking for exactly the reason you describe.

    The thing I’m not getting is why use NServiceBus (or any of the other "competitors") rather than System.Messaging. In the simplest case, which we both seem to be operating in, you’re just creating a message in a private MSMQ. Adding another layer between those seems needless, but I will gladly concede that I’m missing something and I’d love to know what it is.

  • ssmith

    @Bill,

    I’m sure in both our cases we probably could just write to MSMQ directly. I’m using NSB because it has a solid reputation and what appears to be a reasonable userbase, so I figure I can expect more support as I work with it and there will be more samples and patterns and best practices to learn from using it. Also, by working at a higher abstraction level, I should be in a better position to either swap it out (say, for an Azure message queue) or use it for other scenarios that aren’t as easily done at the lower level (which I admit violates YAGNI a bit, but this is my secondary, not primary reason).

  • Bill Brown

    Thank you! That answers my question perfectly. I’m going to stay with YAGNI until I GNI.

  • How do I Change Where MSMQ Messages are Stored or Persisted?

    If you are using MSMQ, either directly or with the help of a package like NServiceBus, you may encounter errors if your server becomes overloaded with messages either due to high load or as a result of a failure in your message handling process. 

  • Jon Kruger

    We use QueueExplorer to view messages in the queue, I like it better than the out of the box stuff.

  • Daniel Halan

    Did a small tool for monitoring, managing and viewing NServiceBus messages, http://blog.halan.se/post/A-MS

  • shop

    The following the five info you must do remember so you are able to manage to produce your particular successful world-wide-web. survey reviews

    [url=http://fdsfrg.blogdetik.com/2012/12/20/louis-vuitton-a-few-indicate-moncler-coats-dozens-of-having-deep-freeze-a-person-to-may-dual-offer-associated-with-pleasant-louis-vuitton-handbags-2012/]shop[/url]

  • Paul

    Thanks. One thing took me a while: The computer management views do not refresh themselves. So after you send a message you have to click ‘refresh’ to see it arriving..

  • Howie Long Jersey

    Chris Young, Rocky Hill: Posted TD runs of 57 and 40 yards and finished with 214 yards on 19 carries in a 39-26 victory at Wethersfield.

  • Kjell-Åke Gafvelin

    You could also use MSMQ Studio (http://www.archonaut.com) to view and move messages.

  • Cheap Newport Cigarettes Wholesale

    Welcome to our high quality Newport and Marlboro Online Store.

  • Paul

    The out of the box stuff is frustrating, esp for developers and testers. Hence “MSMQ Inspector”… http://viridissoftware.com.au/… – I was trying to send you a free copy because your article help out with the development. Thanks!! 🙂

  • seo plugin

    Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword….wait there’s even more Now what if i told you there was a simple WordPress plugin that does all the On-Page SEO, and automatically for you? That’s right AUTOMATICALLY, just watch this 4minute video for more information at. Seo Plugin

  • dauciunas

    You could also use ‘Mqueue Viewer’ – http://www.mqueue.net/
    It’s free and fast and simple. Fully asynchronous. Works for me