RabbitMQ Multiple Queues for Single Exchange

207 views
Skip to first unread message

Tim Burkhart

unread,
Jan 14, 2015, 5:51:23 PM1/14/15
to particula...@googlegroups.com
Helpful information to include
Product name: NServiceBus w/ RabbitMQ
Version: 5.1.2
Stacktrace:
Description:

We have an issue where we have a WebAPI server, but it is load balanced. When another process publishes an event, we want *both* WebAPI servers to receive the message; however, the way that NServiceBus has configured the queues/exchanges, it appears to not support this. Is this true? Both WebAPI servers have the same EndpointName() defined (as "WebService")

So if I go into RabbitMQ Management UI, it shows that there is an exchange of "WebService" and that it binds to a queue named "WebService" and within that queue, it has 2 consumers (both of our WebAPI machines). However, according to http://stackoverflow.com/questions/10620976/rabbitmq-amqp-single-queue-multiple-consumers-for-same-message this yields a round-robin message handling. The messages that are received in the queue will *not* be picked up by both handlers.

So my question is... how do we deal w/ the situation laid out? I think what we really want is for the queue name to be configurable as well as the exchange. We want both WebAPIs to be part of the same exchange, but have different queue names.

Help?

-Tim
Message has been deleted

Tim Burkhart

unread,
Jan 15, 2015, 3:26:09 PM1/15/15
to particula...@googlegroups.com
Thought I had this solved with 

configuration.ScaleOut().UseUniqueBrokerQueuePerMachine();

However, that still doesn't work. The RabbitMQ topology looks like:

--Exchanges--
WebService
WebService.Machine1
WebService.Machine2

--Queues bound to exchange WebService--
WebService

--Queues bound to exchange WebService.Machine1--
WebService.Machine1

--Queues bound to exchange WebService.Machine2--
WebService.Machine2

--Consumers for queue WebService--
IP for machine 1
IP for machine 2

--Consumers for queue WebService.Machine1--
IP for machine 1

--Consumers for queue WebService.Machine2--
IP for machine 2

When I do a publish, it still appears to be routed to the WebService exchange, which goes to the WebService queue, which does the round-robin handling and only goes to one of the machines, but I need it to go to both. Shouldn't it change the configuration on RabbitMQ to fan out the published messages to all of the machines that are subscribing? It doesn't appear to do this by default?

Mauro Servienti

unread,
Jan 26, 2015, 7:18:04 AM1/26/15
to particula...@googlegroups.com
Helpful information to include
Product name: NServiceBus w/ RabbitMQ
Version: 5.1.2
Stacktrace:
Description:

We have an issue where we have a WebAPI server, but it is load balanced. When another process publishes an event, we want *both* WebAPI servers to receive the message; however, the way that NServiceBus has configured the queues/exchanges, it appears to not support this. Is this true? Both WebAPI servers have the same EndpointName() defined (as "WebService")

Can you detail more scenario?
If the WebAPI balanced instances are simply subscribers a suggestion can be to define different queue names so that each endpoint will subscribe to each event and all the subscribers will receive a copy of the event.

Thanks,
.m

Szymon Pobiega

unread,
Jan 26, 2015, 1:27:13 PM1/26/15
to particula...@googlegroups.com
The thing is, the pub/sub pattern that nservicebus implements is a logical architecture pattern. That means that an event is delivered to each logical subscriber. If on physical level a given subscriber happens to be deployed to multiple machines (scaled out) the event is delivered only once to one of the instances. Nsb pub/sub is not designed to implement eg cache sync or things along these lines. Would it make sense in your example to use distributed cache like appfabric to dustribute the result of handling the event to all instances of the web API endpoint?

Szymon
--
You received this message because you are subscribed to the Google Groups "Particular Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftw...@googlegroups.com.
To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.
To view this discussion on the web visit https://groups.google.com/d/msgid/particularsoftware/539dc17b-55a6-46c3-8cc7-649426c997ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mauro Servienti

unread,
Jan 27, 2015, 9:38:24 AM1/27/15
to particula...@googlegroups.com
I agree with Szymon a backplane is the ultimate solution.

.m
--
(no keyboard keys have been killed due to the really annoying OSX spell checker)
Reply all
Reply to author
Forward
0 new messages