[rabbitmq-discuss] Round robin Topic exchange s

Simon MacMullen simon at rabbitmq.com
Thu Feb 7 15:06:35 GMT 2013


OK, so the bad news is that I don't think this kind of routing is 
possible with off the shelf RabbitMQ.

It would be possible to write a custom exchange type quite easily to do 
this *if* the "round robin" part could be replaced by "pick one of the 
routes at random". Essentially you would have an exchange type that 
delegated to the topic exchange for everything, but intercepted the 
queues returned from route/2 and made a random choice.

If the number of routing keys is limited and topic wildcards are not 
needed then you could just have one queue per routing key and have 
consumers consume from all the queues they are interested in, and the 
built in round robin would work for you.

If neither of these constraints hold then I think implementing what you 
want would pose a bigger problem - presumably there would need to be one 
round robin "cursor" per routing key that has ever been published to the 
exchange? So I think you would have a potentially unbounded amount of 
space taken by these cursors, and no way to ever know you can safely GC 
them.

Cheers, Simon


On 07/02/13 11:23, Marc Teichtahl wrote:
> Simon
>
> You are correct in your last statement
>
> For each message to a topic exchange identify the matching queues and
> then round robin between theses.
>
> Sent from my iPhone
>
> On 07/02/2013, at 16:40, Simon MacMullen <simon at rabbitmq.com> wrote:
>
> Sorry, it's not very clear what 'I would like the exchange to round
> robin messages to each consumer queue for the "same" topic' means.
>
> Do you mean something like: for each message, evaluate the routing as
> a topic exchange normally would, giving a list of queues. But then
> rather than routing to all those queues, just route to one, in some
> round robin fashion?
>
> Or something else?
>
> Cheers, Simon
>
> On 07/02/13 10:50, Marc Teichtahl wrote:
>> Im seeking some advise as to how best configure my rabbitMQ exchanges.
>>
>> Im trying to use a topic exchange in a round robin methodology. Each
>> consumer has its own (uniquely) named queue attached to a topic
>> exchange. I would like the exchange to round robin messages to each
>> consumer queue for the "same" topic - lets say *.log for example.
>>
>> I have tried multiple combinations and only seem to be able to
>> simultaneously deliver messages to the consumer queues which effectively
>> means Im processing the message twice, once in each consumer.
>>
>> for clarity I also have a fanout exchange, which I use to "control" the
>> consumers (start, stop etc).this should remain in place in any outcome.
>>
>> Any guidance on how best to achieve the stated outcome would be great.
>>
>>
>> Marc
>>
>>
>>
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
>
>


-- 
Simon MacMullen
RabbitMQ, VMware


More information about the rabbitmq-discuss mailing list