MSMQ is Microsoft Message Queuing developed by Microsoft and deployed in windows operating system. MSMQ Queue ensures that reliable messaging between a client and a Windows Communication Foundation (WCF) service. So first we need to enable this feature in our operating system.
How to enable MSMQ
Press Window key + R, it will open Run window.
Enter ‘Control Panel’ and press ‘OK’ button, it will open control panel,

Click on ‘Programs and Features’,

From the left panel click on ‘Turn Windows features on or off’,

Select ‘Microsoft Message Queue (MSMQ) Server’ and all its child options.
Press ‘OK’ button, it will enable MSMQ for your operating system,

How to create a queue?
Press Window key + R, it will open Run window.
Enter ‘compmgmt.msc’ and press ‘OK’ button, it will open Computer Management window.

Under ‘Services and Applications’ expand ‘Message Queuing’.
Right click on ‘Private Queueus’, select ‘New’ and click on ‘Private Queue’.

Enter queue name, here I have entered ‘myqueue’, which we will use in our application later.

You can find preceding queue under Private Queues.
Select ‘Private Queues’ and you will have list of all queues with details like Name, Label, Number of Messages and Number of Journal Messages.
Right click on ‘myqueue’ and select ‘Properties’,

Check ‘Journal Enabled’ checkbox,
Select the user and allow full permission for this queue,

Verify Queue Service is started
After creating and setting permissions for the queue, we need to verify if queue service is running or not.
Press Window key + R, it will open Run window,
Enter ‘services.msc’ and press ‘OK’ button, it will open Services window.

Change below services status to ‘Running’,
- Message Queuing
- Message Queuing Triggers
- Net.Msmq Listener Adapter

Now let us create Service Application
Create WCF Service Application
Open Visual Studio Editor,
Select ‘File’ menu, expand ‘New’ and click on ‘Projects’,
Select ‘WCF’ from left panel, select ‘WCF Service Application’,
Provide appropriate name, select the location and press ‘OK’ button,

Right click on interface IService1 and rename it to IQueueService,

Right click on Service1.svc and rename it to ‘QueueService.svc’,

Right click on ‘QueueService.svc’ and click on ‘View Markup’,

Change the name of service to ‘WCFNetMSMQ.QueueService’,
- <%@ ServiceHost Language="C#" Debug="true" Service="WCFNetMSMQ.QueueService" CodeBehind="QueueService.svc.cs" %>
Configure service and binding in the web.config under Service Model section. Under service we need to set endpoint with address, binding, contract and binding configuration,
- Address – set queue address with net.msmq, use queuename which we have created previously in the last.
- Binding – binding name which we will configure under bindings section.
- Contract – Provide the interface name
- <services>
- <service name="WCFNetMSMQ.QueueService">
- <endpoint address="net.msmq://localhost/private/myqueue"
- binding="netMsmqBinding"
- bindingConfiguration="MsmqBindingConfig"
- contract="WCFNetMSMQ.IQueueService" />
- </service>
- </services>
Configure binding under netMsmqBinding section. Set security as none.
- <bindings>
- <netMsmqBinding>
- <binding name="MsmqBindingConfig" exactlyOnce="false">
- <security mode="None" />
- </binding>
- </netMsmqBinding>
- </bindings>


















Zdravko StojkoskiPosted May 23, 2017, 12:24 AM
Akshay, I don’t get the point of this at all, i think you have missed a critical point and the other side of it. So when i call this method it is meant to do something? All its doing is storing the messages, what happens if it was successfully sent or not. So is there a second consuming service that then polls the message que for entries? i mean also what’s the point of the que, why not actually just use a database? none of those features are talked about,... it seams like a push / pull system, but you explain one half hwo to do it , and well and simple, but the whole point is actually missed as to how it would use this in a real world example without the other side,...
Anil Kumar PradhanPosted Aug 17, 2016, 7:10 AM
Clear and easy to understand explanation
Sonu ChaudharyPosted Apr 26, 2016, 4:04 AM
nice
Humayun Kabir MamunPosted Apr 24, 2016, 12:57 AM
Nice...
Jaipal ReddyPosted Apr 21, 2016, 8:24 AM
Nice. .
K P Singh ChundawatPosted Apr 20, 2016, 2:42 AM
Thanks for Sharing .
Rahul Kumar SaxenaPosted Apr 19, 2016, 11:08 PM
Good Show