c# - 在我手动点击服务之前,IIS7 中托管的 WCF MSMQ 不会自动检索消息

标签 c# wcf iis-7 msmq was

我看过几个与此相关的帖子,但我还没有找到问题的答案

所以我有一个客户端使用 WCF netmsmq 绑定(bind)向 MSMQ 发送消息。这很好用。

我在本地 IIS7 (Windows 7) 中托管了一个网站,并公开了一个 WCF MSMQ 端点。

当我从客户端发布消息时,消息没有被消费,它们只是永远留在队列中 UNTIL,我手动浏览服务,之后消息被发送到托管的服务在 IIS 中

那么我需要做什么才能通过 IIS 中托管的 WCF 服务自动使用消息?

注意:我刚刚注意到,在 IIS 中调用我的 Web 应用程序中托管的任何 WCF 服务后,唤醒了该服务或其他东西,然后突然消耗了队列消息...

客户端配置

  <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>

服务器配置

  <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>

我尝试过的事情:

  • 消息队列服务正在运行
  • 消息队列触发器服务运行
  • Net.Msmq Listener Adapter 服务正在运行
  • Net.Pipe Listener Adapter 服务正在运行
  • Net.Tcp Listener Adapter 服务正在运行
  • Net.Tcp Port Sharing Service 服务正在运行
  • Distributed Transaction Coordinator 服务正在运行
  • 安装了 MSMQ Active Directory 域服务集成
  • 已安装 MSMQ HTTP 支持
  • 已安装 MSMQ 触发器
  • 已安装 MSMQ 多播支持
  • 已安装 WCF 非 HTTP 激活
  • 已安装 WCF HTTP 激活
  • AppPool 配置为自动启动
  • 我的默认网站包含以下配置:

            <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>
    

最佳答案

自动启动功能由 AppFabric 提供,因此您必须安装它。然后,您将能够使用与此类似的命令行来自动启动您的 WAS 应用程序:

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

关于c# - 在我手动点击服务之前,IIS7 中托管的 WCF MSMQ 不会自动检索消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17952650/

相关文章:

c# - Nhibernate Linq 按名称而不是按 Id 获取对象

c# - 检测 OpenFileDialog 何时返回下载的 URL/URI

c# - backgroundworker+wpf -> 卡住窗口

c# - 如何同时使用两个控制台应用程序调试 WCF 服务

asp.net - UrlRewriting.Net 模块 + IIS7 等于 Page.User == null?

c# - 预期的C#语法错误值

c# - 调用 C# 方法,并使其在 10 秒后返回

wcf - 是否可以在自托管 WCF 服务中使用 ASP.NET MembershipProvider/RoleProvider?

performance - SSL 性能影响

asp.net - IIS 和静态内容?