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, <[email protected]> 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 > [email protected] > https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss > -- You received this message because you are subscribed to the Google Groups "rabbitmq-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rabbitmq-discuss. For more options, visit https://groups.google.com/d/optout.
