[rabbitmq-discuss] Queue/Message Fairness as oppose to Client Fairness
Simon MacMullen
simon at rabbitmq.com
Thu Jun 7 14:35:03 BST 2012
On 06/06/12 09:53, Tapan Thapa wrote:
> I have 1 broker, 1 consumer, many queues. the queues are arbitrary such
> as ACCOUNT_ID.1 ACCOUNT_ID.2 etc. I'm trying to avoid 1 account flooding
> its queue and starving the other accounts.
>
> If the queues look like this (items in array are the messages)
>
> ACCOUNT_ID.1 = [ 1a, 1b, 1c, 1d ]
> ACCOUNT_ID.2 = [ 2a, 2b, 2c, 2d ]
> ACCOUNT_ID.3 = [ 3a, 3b, 3c, 3d ]
>
> I want the consumer to receive messages in a fair order such as = 1a,
> 2a, 3a, 1b, 2b, 3b, ...
>
> Can i achieve above scenario via rabbitmq? If yes how would I do this?
If you want to guarantee that order then you can open three channels,
set the prefetch count to 1 on each, and consume from one queue on each
channel. Then ack the message from 1, then from 2, 3, 1, 2, 3 etc.
That's not the fastest way to go, but it will be the fairest.
Cheers, Simon
--
Simon MacMullen
RabbitMQ, VMware
More information about the rabbitmq-discuss
mailing list