我有一项服务需要在多台机器上运行,从一个队列中选择工作,以确保每项工作只能由一项服务执行。我还需要发布所有要接收的服务的消息,例如重新加载触发器。NServiceBus - 作为订户和工作者服务的应用程序
这可能在nservicebus没有太多的黑客?
我已经证明发布模型和发送模型都适用于我,但只要我的客户端需要处理这两种体系结构,它都将它们视为发送体系结构,而不是所有服务都接收发布方法。
下面是配置文件我到目前为止:
出版商(所有服务都需要接收这些邮件),使用Bus.Publish < ...>(...):
<MsmqTransportConfig InputQueue="ConfigQueue" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig DistributorControlAddress="" DistributorDataAddress="" ForwardReceivedMessagesTo="">
<!-- Message publishers don't require message queues -->
<MessageEndpointMappings /> </UnicastBusConfig>
发件人(只有一个服务可以选择这些了),使用Bus.Send < ...>(...):
<MsmqTransportConfig InputQueue="BrokerQueue" ErrorQueue="error" numberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig DistributorControlAddress="" DistributorDataAddress="" ForwardReceivedMessagesTo="">
<MessageEndpointMappings>
<add Messages="EventMessage, Messages" Endpoint="AgentQueue" />
</MessageEndpointMappings> </UnicastBusConfig>
服务(每个人都有相同的本地队列名称和订阅出版商以上) :
<MsmqTransportConfig InputQueue="AgentQueue" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="NServiceBus.Messages.ReloadMessage, NServiceBus.Messages" Endpoint="ConfigQueue" />
</MessageEndpointMappings> </UnicastBusConfig>
我发现了一个类似的问题,所以会把我的问题在那里: http://stackoverflow.com/questions/1612581/cofiguring-an-endpoint-to-act-both-as-worker-and - 订阅者 – theGecko 2009-12-22 09:14:05