[rabbitmq-discuss] producer/consumer and every n-th message

Michael Klishin michael.s.klishin at gmail.com
Fri Jul 8 08:19:58 BST 2011

2011/7/8 Torsten Curdt <tcurdt at vafer.org>

> Hey,
> Let's say I have n producers sending messages to an exchange and m
> consumers consuming from a single queue bound to that exchange. When a
> consumer does not acknowledges a message (and dies), the message
> should go back into the queue for another consumer to pick it up.
> That should be easy to implement I assume?

Yes, AMQP 0.9.1 has this feature built-in. See tutorial 2:


and a longer example with multiple consumers in the Ruby amqp gem guide:


> I also assume for this scenario a direct exchange would do?
> How bad would be the contention n and m are fairly large?
> ...or do I just need to have enough broker?
Sorry, what are n and m? Message acknowledgements have very low overhead and
redeliveries typically do not happen
often enough to create any contention.

> I would also like to be able to "tap into" the stream of messages
> flowing through the exchange. I assume I could use a fanout exchange
> instead. Have the normal queue with the m consumers and a second queue
> with a single consumer "tapping in".
> As the throughput of message can potentially be very high (which is
> why there are so many consumers) of course a single consumer cannot
> drain the second queue. So my idea was to only care about every n-th
> message.
> Is there a away to tell the fanout consumer to deliver every message
> to Q1 but only every 10th message to Q2?
> How else could one do this?
Every solution I can think of will require producers to keep track of
message sequences. Take a look at


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110708/1abc7cc5/attachment.htm>

More information about the rabbitmq-discuss mailing list