NServiceBus 是否支持同一物理机上同一订阅者的多个实例?
我们有一个与发布者和订阅者组件一起运行的 NService 原型。
如果我们在同一台物理机器上实例化同一订阅者的多个副本,那么只有其中一个会收到任何给定的已发布消息 - 但如果我们在多台机器上各运行一个订阅者,它就会按预期工作。
看来我们不能在同一个盒子上有两个进程,它们都实现 IHandleMessage 并且都订阅同一个消息队列,因为发布者无法知道涉及两个单独的订阅者......
我们对吗?这是设计使然,还是我们配置错误?
We have an NService prototype running with a publisher and a subscriber component.
If we instantiate multiple copies of the same subscriber on the same physical machine, then only one of them will receive any given published message - but if we run one subscriber each on multiple machines, it works as expected.
It appears that we can't have two processes on the same box that both implement IHandleMessage and both subscribe to the same message queue, since the publisher has no way of knowing there's two separate subscribers involved...
Are we right? Is this behaviour by design, or have we mis-configured something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在同一台物理机器上拥有多个订阅者 - 他们只需要独立的输入队列。
这意味着您无法在同一可执行文件和配置文件集合中运行多个流程实例 - 您必须将它们复制到不同的文件夹中并更改另一个实例上的配置。
这基本上就是 NServiceBus 代码中包含的 PubSub 示例所显示的内容。
您现在看到的是每个订阅者(具有相同的输入队列,因此具有相同的“身份”)互相窃取消息 - 基本上是通过使用更多进程来实现多线程。
You can have multiple subscribers on the same physical machine - they just need independent input queues.
This means that you cannot run multiple process instances off the same collection of executables and config files - you must duplicate them in a different folder and change the configuration on the other instance.
This is basically what is shown by the PubSub example included with the NServiceBus code.
What you are seeing right now is each subscriber (with the same input queue and thus the same "identity") stealing messages from each other - basically multithreading by using more processes.