VS 2012/.NET4.5、Windows 8/IIS8 8和64位
使用WCF服务应用程序,到目前为止,我在命名MSMQ队列以匹配服务名称方面看到的所有文档都假定我在IIS网站下面使用的是应用程序或虚拟目录。
此引用自MSDN http://msdn.microsoft.com/en-us/library/ms789042.aspx。
被激活的应用程序必须匹配队列名称的前缀(最长匹配)。 例如,队列名是: msmqWebHost/orderProcessing/service.svc。如果应用程序1有一个虚拟目录/msmqWebHost/orderProcessing,下面有一个service.svc,而应用程序2有一个虚拟目录/msmqWebHost,下面有一个orderProcessing.svc,则应用程序1被激活。如果删除应用程序1,则应用程序2被激活。
还有,http://blogs.msdn.com/b/tomholl/archive/2008/07/12/msmq-wcf-and-iis-getting-them-to-play-nice-part-1.aspx
但是,当您在IIS 7中承载启用MSMQ的服务时,队列名必须与服务的.svc文件的URI匹配。在本例中,我们将在一个名为MsmqService的应用程序中使用名为MsmqService.svc的.svc文件承载服务,因此队列必须称为MsmqService/MsmqService.svc。用于WCF服务的队列应该始终是私有的。
和,http://msdn.microsoft.com/en-us/magazine/cc163357.aspx
需要注意的是,只有当队列具有与.svc文件相同的名称(减去机器名称)时,MSMQ端点的激活才能正确工作。这意味着如果您的服务端点是/server/ app/service.svc,队列名必须是app/service.svc。
MyService.svc文件直接位于IIS的根目录下(在集成模式下使用.NET 4池),因此我做了以下操作:
C:\Windows\System32\inetsrv>appcmd set site "MyWebsite" /+bindings.[protocol='net.msmq',bindingInformation='localhost'] (并检查它是否正确地添加了支持)http,net.tcp,net.msmq在Enabled Protocolsweb.config:<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
<add binding="netMsmqBinding" scheme="net.msmq" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"
multipleSiteBindingsEnabled="true" />
<bindings>
<netMsmqBinding>
<binding name="MsmqBinding_IMyService" exactlyOnce="true"
receiveErrorHandling="Move">
<security mode="None"/>
</binding>
</netMsmqBinding>
</bindings>
<services>
<service name="CompanyName.Service.MyService">
<endpoint name="MyService"
address="net.msmq://localhost/private/MyService.svc"
bindingConfiguration="MsmqBinding_IMyService"
binding="netMsmqBinding" contract="IMyService" >
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>我的服务不会在新消息到达队列和消息停留在队列中时被激活。是因为我没有使用应用程序或虚拟目录,还是因为缺少了什么?
发布于 2013-05-09 11:18:37
通过在默认网站中创建应用程序并修改配置以适应新路径来解决问题。
https://stackoverflow.com/questions/16452609
复制相似问题