NServiceBus 中的多个订阅者

发布于 2024-08-25 02:53:54 字数 763 浏览 3 评论 0原文

我正在开始使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吹梦到西洲 2024-09-01 02:53:54

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!

吃兔兔 2024-09-01 02:53:54

您应该使用它 -

Configure.Instance.Configurer.ConfigureProperty<NServiceBus.Unicast.Transport.Msmq.MsmqTransport>(msmq => msmq.InputQueue, "SomeQueueHere");

确保您使用 MsmqTransport 而不是您提到的 MsmqTransportConfig

You should use this-

Configure.Instance.Configurer.ConfigureProperty<NServiceBus.Unicast.Transport.Msmq.MsmqTransport>(msmq => msmq.InputQueue, "SomeQueueHere");

Make sure you use MsmqTransport and not MsmqTransportConfig as you mentioned.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文