将 NServiceBus 与多个应用程序一起使用,同时充当发布者和订阅者
我正在尝试使用 NServiceBus 使 4 个应用程序一起通信。
所有这些应用程序都必须充当发布者和订阅者。
我创建让它工作的唯一方法是创建一个名为 Server 的“主”队列,在 所有应用程序配置中的 MessageEndpointMappings 都映射到哪个,但我认为这不是好方法...
那么我应该如何在所有这些应用程序上配置 NServiceBus 才能使其正常工作?
应用 1:
<MsmqTransportConfig InputQueue="MyApp1" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
<MsmqSubscriptionStorageConfig Queue="Subscriptions" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyApp.Messages" Endpoint="Server" />
</MessageEndpointMappings>
</UnicastBusConfig>
应用 2:
<MsmqTransportConfig InputQueue="MyApp2" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
<MsmqSubscriptionStorageConfig Queue="Subscriptions" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyApp.Messages" Endpoint="Server" />
</MessageEndpointMappings>
</UnicastBusConfig>
应用 3:
<MsmqTransportConfig InputQueue="MyApp3" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
<MsmqSubscriptionStorageConfig Queue="Subscriptions" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyApp.Messages" Endpoint="Server" />
</MessageEndpointMappings>
</UnicastBusConfig>
应用 4:
<MsmqTransportConfig InputQueue="MyApp4" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
<MsmqSubscriptionStorageConfig Queue="Subscriptions" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyApp.Messages" Endpoint="Server" />
</MessageEndpointMappings>
</UnicastBusConfig>
I'm trying to use NServiceBus to make 4 applications communicating together.
All these applications have to act as Publisher and Subscriber.
The only way i founded ti get it workiing is to create a "master" queue named Server, on
which MessageEndpointMappings in all applications configuration is mapped to, but i think it's not the good way ...
So how should i configure NServiceBus on all these application to get this working ?
Application 1 :
<MsmqTransportConfig InputQueue="MyApp1" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
<MsmqSubscriptionStorageConfig Queue="Subscriptions" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyApp.Messages" Endpoint="Server" />
</MessageEndpointMappings>
</UnicastBusConfig>
Application 2 :
<MsmqTransportConfig InputQueue="MyApp2" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
<MsmqSubscriptionStorageConfig Queue="Subscriptions" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyApp.Messages" Endpoint="Server" />
</MessageEndpointMappings>
</UnicastBusConfig>
Application 3 :
<MsmqTransportConfig InputQueue="MyApp3" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
<MsmqSubscriptionStorageConfig Queue="Subscriptions" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyApp.Messages" Endpoint="Server" />
</MessageEndpointMappings>
</UnicastBusConfig>
Application 4 :
<MsmqTransportConfig InputQueue="MyApp4" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
<MsmqSubscriptionStorageConfig Queue="Subscriptions" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyApp.Messages" Endpoint="Server" />
</MessageEndpointMappings>
</UnicastBusConfig>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NServiceBus 希望您遵循仅由一项服务发布的特定消息类型的模式。通常,每个服务都会有一个“消息”组件,例如:
如果您想从所有四个应用程序发布相同的消息类型,您可以使用 Bus.Send() 将消息发送到中央事件发布者服务,然后中央事件发布者服务可以使用 Bus.Send() 将消息发送到中央事件发布者服务。发布()它。
NServiceBus prefers you follow the pattern of a particular message type being published by one service only. Typically you will have a 'messages' assembly for each service, eg:
If you want to publish the same message type from all four applications, you can Bus.Send() the message to a central event publisher service, which could then Bus.Publish() it.