[rabbitmq-discuss] rabbitmq-c examples - producer/consumer work queue not working ???
Alan Antonuk
alan.antonuk at gmail.com
Fri Jun 13 20:51:41 BST 2014
The amqp_consume example sets no_ack = 1, so the broker sends messages to
consumers as fast as possible without waiting for any acknowledgement from
clients.
To make it work more like a work-queue, you'd need to set no_ack = 0,
requiring the consumer to send a basic.ack (amqp_basic_ack). In addition
you'll also need to set a qos (using amqp_basic_qos) which will limit the
number of unacked messages that each consumer can have. (to be pedantic -
the qos parameter is per-channel: see:
http://www.rabbitmq.com/consumer-prefetch.html )
-Alan
On Fri Jun 13 2014 at 12:30:38 PM, <ktran0003 at gmail.com> wrote:
> I tried out the producer/consumer examples included in rabbitmq-c as
> follows:
> One producer and two consumers
>
> In two separate terminal windows: ./amqp_consumer localhost 5672
> In one terminal window: %./amqp_producer localhost 5672 1 6
>
> Both consumers show:
> 6737 ms: Received 1 - 1 since last report (0 Hz)
> 6737 ms: Received 2 - 1 since last report (16949 Hz)
> 7739 ms: Received 3 - 1 since last report (0 Hz)
> 8737 ms: Received 4 - 1 since last report (1 Hz)
> 9738 ms: Received 5 - 1 since last report (0 Hz)
> 10737 ms: Received 6 - 1 since last report (1 Hz)
>
> This is a surprise to me. I thought the messages should be sent
> round-robin to both consumers (like the python example) so they would not
> receive everything like a fanout.
> Do I miss something? If this is the way it's supposed to work, how I
> change the code to make it work like a work queue?
>
> Thanks,
> -Kim
>
>
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140613/59fd4aff/attachment.html>
More information about the rabbitmq-discuss
mailing list