views:

266

answers:

1

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

A: 

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();
Andrew Smith