[rabbitmq-discuss] checking no of message in queue
Emile Joubert
emile at rabbitmq.com
Tue Mar 22 13:27:34 GMT 2011
Hi cheepu,
Op 22/03/2011 10:34, het cheepu geskryf:
>
> Hi,
>
> I am using the QueueingConsumer
If you are using QueueingConsumer then the broker will deliver messages
to the consumer, indepently from whether you dequeue them from the
QueueingConsumer using nextDelivery(). That is why the number of
messages is 0 in step 2.
I would suggest using the "rabbitmqctl list_queues" command to confirm
that nextDelivery() makes no difference to the broker.
> and using the following code for the explicit acknowledgement
>
> delivery = consumer.nextDelivery(500);
> channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
This explicit message acknowledgement shows that you are not using
auto-ack, as I previously thought.
> I am using java library for this and how can i get in this case the number
> of messages?
Your previous sample code using passive queue declaration with
getMessageCount() is correct.
---
As an aside, you can use QoS, which is a consumer-initiated means of
flow control in this situation. Setting prefetchCount to 1 will prevent
all messages from being sent to the QueueingConsumer immediately without
acknowledgement. See the method spec here:
http://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos
http://www.rabbitmq.com/amqp-0-9-1-quickref.html#basic.qos
Regards
Emile
More information about the rabbitmq-discuss
mailing list