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

109 views
Skip to first unread message

Andrew

unread,
Nov 23, 2009, 6:26:36 AM11/23/09
to Rhino Tools Dev
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 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>

This works fine and dandy for 1 publisher and 1 subscriber. However,
what I want to acheive is 2 subscribers listening to the same message
and each receiving their own copy of the message. So, I just copied
and pasted the subscriber exe and config file file to create my second
subscriber. I've tried various config settings but no matter what I
do, I only end up with competing consumers.

I would've assumed that I could define a different endpoint for each
receiver bus (and leave the messages element above still pointing to
"msmq://localhost/my.queue"). In this way, each receiver can have
their own queue. I.e. the configuration for the subscriber looks like:

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

But, if I try to do this, I don't receive any messages at all (even
though from the log files, it looks like it's doing the right thing).

This must be possible so I'm sure I've missed something obvious here.
Any help much appreciated.

Cheers

Ayende Rahien

unread,
Nov 24, 2009, 6:30:54 AM11/24/09
to rhino-t...@googlegroups.com
Every subscriber needs to have its own queue


--

You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group.
To post to this group, send email to rhino-t...@googlegroups.com.
To unsubscribe from this group, send email to rhino-tools-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=.



Andrew

unread,
Nov 24, 2009, 10:41:04 AM11/24/09
to Rhino Tools Dev
Ayende, thanks for reply. I have tried using a separate queue per
subscriber. For example, (with just 1 publisher and 1 subscriber) I
have a publisher queue called "my.queue" and a subscriber queue called
"my.subscriber1". Configured as below. However, with this
configuration I do not receive any messages. I have tried with both
OnewayRhinoServiceBusFacility and the regular RhinoServiceBusFacility.

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

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

Log from the receiver:
----------------------
DEBUG Rhino.ServiceBus.Impl.DefaultServiceBus [(null)] Starting the
bus for Uri: msmq://computername/my.subscriber1
DEBUG Rhino.ServiceBus.Impl.DefaultServiceBus [(null)] Initating
subscription storage as message module:
Rhino.ServiceBus.Msmq.MsmqSubscriptionStorage
DEBUG Rhino.ServiceBus.Msmq.AbstractMsmqListener [(null)] Starting
msmq transport on: Uri: msmq://computername/my.subscriber1
DEBUG Rhino.ServiceBus.Msmq.MsmqSubscriptionStorage [(null)]
Initializing msmq subscription storage on: msmq://localhost/my.subscriber1;subscriptions
INFO Rhino.ServiceBus.Impl.DefaultServiceBus [(null)] Subscribing
My.Messages.Namespace.MyMessage on msmq://localhost/my.queue
DEBUG Rhino.ServiceBus.Msmq.OpenedQueue [(null)] Sending message
Rhino.ServiceBus.Messages.AddSubscription to COMPUTERNAME\private$
\my.queue, reply: COMPUTERNAME\private$\my.subscriber1
DEBUG Rhino.ServiceBus.Msmq.MsmqTransport [(null)] Send message
Rhino.ServiceBus.Messages.AddSubscription to Uri: msmq://computername/my.queue


Thanks for your help,
Andrew


On Nov 24, 11:30 am, Ayende Rahien <aye...@ayende.com> wrote:
> Every subscriber needs to have its own queue
>
> > rhino-tools-d...@googlegroups.com<rhino-tools-dev%2Bunsu...@googlegroups.com>
> > .

Ayende Rahien

unread,
Nov 24, 2009, 10:48:56 AM11/24/09
to rhino-t...@googlegroups.com
How are you setting up the container?
I _think_ that you need set the facility id to be rhino.esb alone.

To unsubscribe from this group, send email to rhino-tools-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en.



Andrew

unread,
Nov 24, 2009, 11:37:46 AM11/24/09
to Rhino Tools Dev
Ayende,

No joy with renaming them, I'm afraid.

Producer code:
--------------

var container = new WindsorContainer(new XmlInterpreter
("RhinoEsbSettings.xml"));

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

var bus = container.Resolve<IOnewayBus>();

while (true)
{
MyMessage msg = new ....
bus.Send(msg);

Console.ReadLine();
}

Consumer code:
--------------
static void Main(string[] args)
{
var container = new WindsorContainer(new XmlInterpreter
("RhinoEsbSettings.xml"));
container.Register(Component.For<ConsumerOf<MyMessage>>
().ImplementedBy<MyConsumer>().LifeStyle.Transient.Named
("SomeConsumer"));

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

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

bus.Start();
Console.WriteLine("Ready to receive messages");
Console.ReadLine();
}

....

public class MyConsumer : ConsumerOf<MyMessage>
{
public void Consume(MyMessage message)
{
Console.WriteLine("Received message");
}
}


Thanks again,
Andrew


On Nov 24, 3:48 pm, Ayende Rahien <aye...@ayende.com> wrote:
> How are you setting up the container?
> I _think_ that you need set the facility id to be rhino.esb alone.
>
> > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/rhino-tools-dev?hl=.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Rhino Tools Dev" group.
> > To post to this group, send email to rhino-t...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rhino-tools-d...@googlegroups.com<rhino-tools-dev%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rhino-tools-dev?hl=en.
>
>
Reply all
Reply to author
Forward
0 new messages