NetMsmqBinding Brain Dump

I started experimenting with WCF’s NetMsmqBinding and found the abstraction to be a bit tricky. WCF takes care of all the MSMQ details and all you need to do is define the contract and do configuration. The following are some notes about that process.


msmq wcf and iis getting them to play nice

AutoFac WAS Hosting and Non-HTTP Activation

Windows Components Installed

Microsoft Message Queue (MSMQ) Server > MSMQ Server Core

Microsoft .NET Framework > Windows Communication Foundation Non-HTTP Activation

IIS 7 Configuration

  1. Add net.msmq to the list of enabled protocols. In IIS, Web App -> Advanced Settings -> Enabled Protocols. It is a comma separated list (http,net.msmq).
  2. Make sure Client and Service have correct permissions to access the private queue

MSMQ Config

Add NETWORK SERVICE to the new MSMQ (windows 7 that is in Computer Managment -> Services and Applications -> Message Queuing

C# code to create initialize private queue

The queue name must match the URI of your service’s .svc file according to this

  // Create and connect to a private Message Queuing queue.
if (!MessageQueue.Exists(@".\Private$\JangoFettClient/CloneService.svc"))
    // Create the queue if it does not exist.

Example Service Config

        <binding name="MsmqBindingNonTransactionalNoSecurity"
            <security mode="None"/>
<service name="JangoFettClient.CloneService">
    <endpoint name="msmq" 
              contract="JangoFettClient.ICloneOrderProcessor" />

Example Service

Example of data contract that would automatically become the listener and pull the items from MSMQ via WCF

namespace JangoFettClient
    public class CloneService : ICloneOrderProcessor
        private readonly ILog _logger;

        public CloneService(ILog logger)
            _logger = logger;

        public void SendMessage(CloneOrder request)
            _logger.Info("Message received from MSMQ");

Errors with easy fixes

The protocol ‘net.msmq’ is not supported. Add net.msmq to the list of enabled protocols. See IIS 7 Configuration above for more information.

Leave a Reply

Your email address will not be published. Required fields are marked *