如何使用Rhino Service Bus为多个订阅者配置发布订阅?

发布于 2024-08-12 17:31:15 字数 1058 浏览 5 评论 0原文

我正在尝试使用 Rhino Service Bus 在 1 个发布者和多个订阅者之间设置发布-订阅。然而,我似乎得到的只是竞争消费者(消息在一个消费者或另一个消费者之间分发,但不会发送给两者)。

我当前的发布者配置如下所示(注意:我正在使用新的 OnewayRhinoServiceBusFacility,因此我不需要在发送者中定义总线元素)我

<facility id="rhino.esb.sender" >
        <messages>
            <add name="My.Messages.Namespace" endpoint="msmq://localhost/my.queue"/>
        </messages>
</facility>

当前的订阅者配置如下所示:

<facility id="rhino.esb.receiver" >
    <bus threadCount="1" numberOfRetries="5" endpoint="msmq://localhost/my.queue" DisableAutoQueueCreation="false" />
    <messages>
        <add name="My.Messages.Namespace" endpoint="msmq://localhost/my.queue" />
    </messages>
</facility>

我有 2 个启动的简单命令行应用程序发布者和订阅者。我只需复制并粘贴订阅者箱即可设置 2 个订阅者。我的消息处理程序如下所示:

public class DummyReceiver : ConsumerOf<MyMessageType>
{
    public void Consume(MyMessageType message)
    {
                    // ......
            }
    }

有什么想法吗?干杯

I am trying to set up pub-sub between 1 publisher and multiple subscribers using Rhino Service Bus. However, all I ever seem to get is competing consumers (where messges are distributed between 1 consumer or the other, but not sent to both).

My current publisher configuration looks like this (Note: I'm using the new OnewayRhinoServiceBusFacility so I don't need to define a bus element in the sender)

<facility id="rhino.esb.sender" >
        <messages>
            <add name="My.Messages.Namespace" endpoint="msmq://localhost/my.queue"/>
        </messages>
</facility>

My current subscriber configuration looks like this:

<facility id="rhino.esb.receiver" >
    <bus threadCount="1" numberOfRetries="5" endpoint="msmq://localhost/my.queue" DisableAutoQueueCreation="false" />
    <messages>
        <add name="My.Messages.Namespace" endpoint="msmq://localhost/my.queue" />
    </messages>
</facility>

I have 2 simple command line apps which start up publisher and subscriber. I just copy and paste subscriber bin to set up 2 subscribers. My message handler looks like this:

public class DummyReceiver : ConsumerOf<MyMessageType>
{
    public void Consume(MyMessageType message)
    {
                    // ......
            }
    }

Any ideas? Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

我偏爱纯白色 2024-08-19 17:31:15

哎哟!在我的生产者代码中使用发送而不是发布。从另一个示例复制它并忘记更改。

因此,作为参考,我的发布者代码如下:

var container = new WindsorContainer(new XmlInterpreter("RhinoEsbSettings.xml"));
RhinoServiceBusFacility facility = new RhinoServiceBusFacility();
container.Kernel.AddFacility("rhino.esb", facility);

var bus = container.Resolve<IStartableServiceBus>();
bus.Start();

MyMessageType msg = new ...
bus.Publish(msg);

我的消费者启动代码如下:

var container = new WindsorContainer(new XmlInterpreter("RhinoEsbSettings.xml"));
container.Register(Component.For<ConsumerOf<MyMessageType>>().ImplementedBy<DummyReceiver>().LifeStyle.Transient.Named("Consumer"));

RhinoServiceBusFacility facility = new RhinoServiceBusFacility();
container.Kernel.AddFacility("rhino.esb", facility);

var bus = container.Resolve<IStartableServiceBus>();
bus.Start();

Doh! Was using Send instead of Publish in my producer code. Had copied it from another example and forgot to change.

So, for reference my publisher code is like this:

var container = new WindsorContainer(new XmlInterpreter("RhinoEsbSettings.xml"));
RhinoServiceBusFacility facility = new RhinoServiceBusFacility();
container.Kernel.AddFacility("rhino.esb", facility);

var bus = container.Resolve<IStartableServiceBus>();
bus.Start();

MyMessageType msg = new ...
bus.Publish(msg);

And my consumer startup code is like this:

var container = new WindsorContainer(new XmlInterpreter("RhinoEsbSettings.xml"));
container.Register(Component.For<ConsumerOf<MyMessageType>>().ImplementedBy<DummyReceiver>().LifeStyle.Transient.Named("Consumer"));

RhinoServiceBusFacility facility = new RhinoServiceBusFacility();
container.Kernel.AddFacility("rhino.esb", facility);

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