Microsoft Message Queuing

Microsoft Message Queuing

In my last post “Why Apache ActiveMQ isn’t good for .NET developers?” I described the situation when I couldn’t solve my issue using ActiveMQ. Therefore, I tested another message queue system – Microsoft Message Queuing (MSMQ). Because this system is a Microsoft’s product, it is fully supported by .NET Framework. I don’t know why I was prejudiced against this system in the beginning. In fact, it is a useful and simple message queue system for any .NET developer. Why? See below.

MSMQ  at a glance

Microsoft Message Queuing (MSMQ) is a message queue implementation developed by Microsoft and deployed in its Windows operating systems since Windows NT 4 and Windows 95. Current version 4.0 is released with Windows Vista and Windows Server 2008. It is a very mature system and has a long list of features, like: triggers, connectionless messaging, guaranteed message delivery and many others. For me a very important function is message peeking. In the below example I will show how it works.

Why is it so good? – Example

To answer this question I demonstrate how simple I made my non-trivial system. My issue was to make sample applications: two clients and a server, which are communicating by messages. Detailed description of this issue is in my previous post. I made this system using MSMQ and .NET Framework 3.5 in 5 steps. 1. Installing MSMQ in your Windows system. In Vista: Open “Control Panel -> Programs ->Turn Windows features on or off”. Find and check “Microsoft Message Queue(MSMQ) Server”. MSMQ_install 2. Creating message class I make a class that defines the message structure. You can define any class and send it by MSMQ.

3. Creating Client 1 class This class creates queue if it doesn’t exist and sends message to it.

4. Creating Server class Class creates or open queue receives messages and processes them by worker object. Worker can only process single message. It returns control to server object when processing is done.

5. Creating Client 2 class Class reads all messages in the queue, checks its content and adds it to the list . It is a simple queue monitor.

And that is all. Application works great and does exactly what I wanted. After working with ActiveMQ NMS API I didn’t expect that making this system would go so easily and fast. I’m delighted.

Summary

The main advantages for me are:

  • API is very simple – in several lines of code I have a wide access to queue system.
  • API is well documented (by MSDN).
  • I don’t need any additional server or library – I need only Windows and .NET Framework.
  • Great thing is also that I can send any kind of objects and even streams.
  • I can also look up what is going on with my queues. By “Computer Management” tool in Control Panel as well as by code.
  • It is free.

Main disadvantage:

  • MSMQ is only for Windows users.

Share your opinion and experience with us below or meet us on Twitter: @GOYELLO.

Thanks to Karol Świder for helping me to write this blog post.
IT guy with head full of ideas, strongly oriented on achieving great goals in life. Currently working for GOYELLO, place where I grow.
  • Mark

    I wouldn't say MSMQ is excellent at all. But rather it is your only choice if you are a pure Microsoft “Shop” [I despise that term]. I tried using it a few years ago with .Net to do some triggering I think. I couldn't get it to work whatever it was.

    Using ActiveMQ is the correct choice if you work in a mixed environment. If not, either learn something new or stick with what Bill gives you. :(.

  • maciejgren

    Hi,
    thank you for your comment. I understand your opinion but I have to disagree. Like you said you used it few years ago. I can imagine that then MSMQ offered less functionalities than now. After my review of other systems I had to conclude that the best is to return to the “what Bill gives me” because other systems offered more but also limited me in areas that I wanted to have control.

    For sure ActiveMQ has their own placement in the market where it is better than using pure MSMQ. It is important to know that the decision has to be careful because you not only gain, but lose as well.

  • Mark

    Not sure we disagree. And I don't have an opinion. I have experience.

    I'd hope that MSMQ does more. But I have used their products for years and MSMQ is one thing that doesn't seem to be important to their users nor them, sadly. But even more sad, it is not alone in this regard.

    If you can stay within the “gutter-bumpers” that Microsoft provides then all is well. But I never can seem to be able to do that. 🙁

  • Eugenis

    ActiveMQ can be very easy as well. You need to look at Spring .NET Spring NMS.

  • Nice Post I already digged this

    respect
    ricky marten
    ______________________________________________

  • Pingback: prgvlnby()

  • It looks good,I have learn a recruit!
    Recently,I found an excellent online store, the “http://www.air-jordan-18.com are completely various, good quality and cheap price,it’s worth buying!

  • I totally agree the standpoint of upstairs, and I believe this will be a trend. I often come this forum , rom here I learn much and know the newest tide! the content here constantly update shoe and I love it! Another I know some websites which often update their contents, you guys should browse if you are free.http://www.assure-every.com

  • Hhe article's content rich variety which make us move for our mood after reading this article. surprise, here you will find what you want! Recently, I found some wedsites which commodity is research-laboratory colorful of fashion. Such as that worth you to see. Believe me these websites won’t let you down.

  • I have a long history with MSMQ and unfortunately, have grown to dislike it immensely. As of MSMQ 3.0 they switched to using kernal memory for MSMQ and the result is a very unforgiving blue screen if your message store gets too large. You can set limits on the store size to avoid this, but in my opinion, it still gives you less storage than I would like in a high transaction environment. For instance we pump 20+ million of messages through our queues a day. If there is a failure somewhere and we get backups of 400k messages (which can happen quickly), we may experience a server crash or at least MSMQ gets very, very s-l-o-w. It's too bad the size of the message store actually makes performance degrade because it's really the last thing you want to have happen when your system starts to queue up. This is why we're moving to ActiveMQ. It provides much much greater flexibility and capacity.

  • Rathi Emails

    Good Article very useful,thank you.

  • vaibhav korade

    Hello,

    I am using MSMQ communication between TWO systems. Both the systems are in different domains. We are using private queue for the exchanging the message. One Machine (Say Machine A) is in domain. Second machine (Say Machine B) is not present in this domain.
    it is a Workgroup machine. Now my queues are present on Machine B. I am able to do communication if Queues having “Anonymous Logon” and “Everyone” Access on machine B. But Client is not allowing “Anonymous Logon” and “Everyone” Access in production. What is alternate solution. Please help out me in this scenario.
    Thanks in Advance.