Search code examples
c#wcfiis-7msmqwas

WCF MSMQ hosted in IIS7 WAS not retrieving messages automatically until I MANUALLY hit the service


I have seen several posts related to this but I have not found an answer to my problem

So I have a client sending messages to a MSMQ using WCF netmsmq binding. This works fine.

I have a web site hosted in my local IIS7 (Windows 7) exposing a WCF MSMQ endpoint.

When I publish a message from the client, the messages are not being consumed, they just stay in queue forever UNTIL, I manually browse the service, after that the messages are sent to the service hosted in IIS

So what do I need to do in order to consume the messages automatically by my WCF service hosted in IIS?

Note: I just noticed that after calling any WCF service hosted in my web applicaiton in IIS wakes up the service or something and suddenly the queue messages are consumed...

Client Configuration

  <system.serviceModel>
    <client>
      <endpoint name="Service.ServiceContracts.QueueLoggingService NET MSMQ"
                address="net.msmq://localhost/private/Service.WebHost/QueueLoggingService.svc"
                binding="netMsmqBinding"
                contract="Service.ServiceContracts.IQueueLoggingService">
      </endpoint>
    </client>
    <bindings>
      <netMsmqBinding>
        <binding exactlyOnce="true" durable="true" maxRetryCycles="15" receiveRetryCount="15">
          <security mode="None">
            <message clientCredentialType="None" />
            <transport msmqAuthenticationMode="None" />
          </security>
        </binding>
      </netMsmqBinding>
    </bindings>
  </system.serviceModel>

Server configuration

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
    </serviceHostingEnvironment>
    <services>
      <service name="Service.ServiceImplementations.QueueLoggingService">
        <endpoint 
                  address="net.msmq://localhost/private/Service.WebHost/QueueLoggingService.svc"
                  binding="netMsmqBinding"
                  contract="Service.ServiceContracts.IQueueLoggingService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <bindings>
      <netMsmqBinding>
        <binding exactlyOnce="true" durable="true" maxRetryCycles="15" receiveRetryCount="15">
          <security mode="None">
            <message clientCredentialType="None" />
            <transport msmqAuthenticationMode="None" />
          </security>
        </binding>
      </netMsmqBinding>
    </bindings>
  </system.serviceModel>

Things that I have tried:

  • Message Queuing service running
  • Message Queuing Triggers service running
  • Net.Msmq Listener Adapter service running
  • Net.Pipe Listener Adapter service running
  • Net.Tcp Listener Adapter service running
  • Net.Tcp Port Sharing Service service running
  • Distributed Transaction Coordinator service running
  • MSMQ Active Directory Domain Service Integration installed
  • MSMQ HTTP Support installed
  • MSMQ Triggers installed
  • MSMQ Multicasting support installed
  • WCF Non-HTTP Activation installed
  • WCF HTTP Activation installed
  • The AppPool is configured to start automatically
  • My Default Web Site contains the following configuration:

            <application path="/Service.WebHost" applicationPool="MyGenericAppPool" enabledProtocols="net.msmq, http">
                <virtualDirectory path="/" physicalPath="C:\Some Path\Service.WebHost" />
            </application>
    
            <bindings>
                <binding protocol="http" bindingInformation="*:80:" />
                <binding protocol="net.tcp" bindingInformation="808:*" />
                <binding protocol="net.pipe" bindingInformation="*" />
                <binding protocol="net.msmq" bindingInformation="localhost" />
                <binding protocol="msmq.formatname" bindingInformation="localhost" />
            </bindings>
    

Solution

  • The autostart functionality is provided by AppFabric, so you must install it. Then, you will be able to use a command line similar to this one, in order to auto-start your WAS application :

    appcmd.exe set app /app.name:YourApplication /serviceAutoStartEnabled:True /serviceAutoStartMode:All