我们有一个 WCF 服务,它使用 NetMessagingBinding 侦听 Azure 服务总线队列。然而,我们发现有时服务似乎在消息到达时停止被通知,即我们看到队列建立但我们的实例都没有处理消息。
如果我们然后重新启动实例,它们会立即开始再次从队列中接收消息。
在我们的工作角色中打开 WCF 服务的代码:
var endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(ICacheKeyExchangeWithSession)))
{
Address = new EndpointAddress(new Uri(baseAddress + QueueNames.Cache)),
Binding = new NetMessagingBinding(),
};
var endpointBehavior = new TransportClientEndpointBehavior
{
TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(id, secret),
};
endpoint.EndpointBehaviors.Add(endpointBehavior);
host = new ServiceHost(typeof(DataService), new Uri[] { });
host.AddServiceEndpoint(endpoint);
host.Open();
我们在 app.config 中没有针对 NetMessagingBinding 的特定配置:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<extensions>
<behaviorExtensions>
<add name="transportClientEndpointBehavior" type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</behaviorExtensions>
<bindingElementExtensions>
<add name="netMessagingTransport" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingTransportExtensionElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingElementExtensions>
<bindingExtensions>
<add name="netMessagingBinding" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingBindingCollectionElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
</system.serviceModel>
有任何想法吗?