开发者

How to configure pub sub for multiple subscribers with Rhino Service Bus?

开发者 https://www.devze.com 2022-12-12 06:07 出处:网络
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 cons

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


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();
0

精彩评论

暂无评论...
验证码 换一张
取 消