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”. 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.
We process cookies and make them available to Google Analytics (a service provided by Google, Inc.) to improve the performance of the website, to learn your preferences about using it and to tailor it to your needs. The data will be anonymised before being transmitted. If you do not agree to this, you may disable cookies in your browser. If you do not change your browser settings, you accept the fact that it saves cookies.