NServiceBus 中的多个订阅者
我正在开始使用 NServiceBus,并对 Pubsub 示例有疑问。
我的目的是让 Publisher1 的多个实例运行并接收从发布者发送的消息。我还攻击了 Publisher,使其仅发送 eventMessage 类型的消息。
但是,如果我启动发布者和 Subscriber1 的三个实例,则一次只有一个实例收到消息。
这是为什么?是配置设置还是其他什么?
这是我尝试过的方法,它返回异常“启动端点时出现异常,已记录错误。原因:在配置组件之前无法配置属性。请先调用“配置”。”:
using NServiceBus;
namespace Subscriber1
{
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
{
}
public class OverrideInputQueue : IWantCustomInitialization
{
public void Init()
{
Configure
.Instance
.Configurer
.ConfigureProperty<NServiceBus.Config.MsmqTransportConfig>(t => t.InputQueue, "testQueue");
}
}
}
/J
I'm getting started with NServiceBus and have a question about the Pubsub sample.
My intention was to have multiple instances of Publisher1 running and receiving the message sent from the publisher. I also hacked the Publisher to only send messages of the eventMessage type.
But if I start the publisher and three instances of Subscriber1, only one of them gets the message at a time.
why is that? Is it a config setting or something else?
This is what I've tried which returns an exception "Exception when starting endpoint, error has been logged. Reason: Cannot configure property before the component has been configured. Please call 'Configure' first.":
using NServiceBus;
namespace Subscriber1
{
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
{
}
public class OverrideInputQueue : IWantCustomInitialization
{
public void Init()
{
Configure
.Instance
.Configurer
.ConfigureProperty<NServiceBus.Config.MsmqTransportConfig>(t => t.InputQueue, "testQueue");
}
}
}
/J
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NServiceBus 假设每个进程有一个输入队列。确保为每个订阅者配置了唯一的输入队列。如果不是,所有三个都会轮询同一队列,产生您所描述的行为。
为此,您可能需要将 sub1 复制粘贴到 3 个不同的文件夹,修改 app.config 并启动它们。
希望这有帮助!
NServiceBus assumes that you have one input queue per process. Make sure that each of your subscribers are configured with a unique input queue. If not all three will be polling the same queue producing the behavior you're describing.
To do this you would probably have to copy paste sub1 to 3 different folders, modfying the app.config and start them up.
Hope this helps!
您应该使用它 -
确保您使用 MsmqTransport 而不是您提到的 MsmqTransportConfig。
You should use this-
Make sure you use MsmqTransport and not MsmqTransportConfig as you mentioned.