我需要开发一个Windows Server Service Bus主题订阅者(是的,Windows Server而不是Azure),并且为了从阅读中抽象出来,启动工作线程,...,循环并利用AppFabric管理能力,我有以下想法:
问题是:
提前致谢。
答案 0 :(得分:3)
如何连接WCF和Service Bus的基本机制在Azure和Server版本之间是相同的。 You can use this post as a good starting point:
两者之间的主要区别在于端点地址,以及如何处理身份验证(因为服务器中没有ACS)。 This post has some useful information on it.
现在,具体回答你的问题:
发布商可以从技术上直接推送到服务总线队列,但如果您使用合同,它会更好。这里的问题不是如何推送,而是如何以服务可以理解的方式构建消息。拥有WCF合同将允许您抽象序列化/反序列化。
对于配置,典型方案是使用netMessagingBinding的WCF服务。我提到的第一篇文章有关于配置的信息。只需确保更新auth和端点地址片段以匹配服务总线服务器。
答案 1 :(得分:3)
为了帮助解决未来相关问题,需要进行配置
发布商和订阅者配置都需要扩展程序:
<extensions>
<behaviorExtensions>
<add name="transportClientEndpointBehavior" type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</behaviorExtensions>
<bindingExtensions>
<add name="netMessagingBinding" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingBindingCollectionElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
注意:发布者和订阅者都需要Microsoft.ServiceBus程序集。该软件包位于Nuget。
订阅者端配置:
<bindings>
<netMessagingBinding>
<binding name="messagingBinding" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:03:00" sendTimeout="00:03:00" sessionIdleTimeout="00:01:00" prefetchCount="-1">
<transportSettings batchFlushInterval="00:00:01" />
</binding>
</netMessagingBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="securityBehavior">
<messageInterceptorBehavior/>
<transportClientEndpointBehavior>
<tokenProvider>
<windowsAuthentication>
<stsUris>
<stsUri value="https://[SERVER]:9355/[NAMESPACE]" />
</stsUris>
</windowsAuthentication>
</tokenProvider>
</transportClientEndpointBehavior>
</behavior>
<endpoint listenUri="sb://[SERVER]/[NAMESPACE]/[TOPIC]/Subscriptions/[SUBSCRIPTIONNAME]"
address="sb://[SERVER]/[NAMESPACE]/[TOPIC]"
behaviorConfiguration="securityBehavior" binding="netMessagingBinding"
bindingConfiguration="messagingBinding" name="InsuranceService"
contract="[WCF_CONTRACT_NAME]" />
发布商配置:
<bindings>
<netMessagingBinding>
<binding name="InsuranceService" closeTimeout="00:03:00" openTimeout="00:03:00"
receiveTimeout="00:03:00" sendTimeout="00:03:00" prefetchCount="-1"
sessionIdleTimeout="00:01:00">
<transportSettings batchFlushInterval="00:00:01" />
</binding>
</netMessagingBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="securityBehavior">
<messageInterceptorBehavior/>
<transportClientEndpointBehavior>
<tokenProvider>
<windowsAuthentication>
<stsUris>
<stsUri value="https://[SERVER]:9355/[NAMESPACE]" />
</stsUris>
</windowsAuthentication>
</tokenProvider>
</transportClientEndpointBehavior>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="sb://[SERVER]/[NAMESPACE]/[TOPIC]"
behaviorConfiguration="securityBehavior" binding="netMessagingBinding"
bindingConfiguration="InsuranceService" contract="PushVoucherService.ISubscriber"
name="InsuranceService" />
</client>