[rabbitmq-discuss] checking no of message in queue
cheepu
shammi at arosys.com
Tue Mar 22 10:34:20 GMT 2011
Hi,
I am using the QueueingConsumer and using the following code for the
explicit acknowledgement
delivery = consumer.nextDelivery(500);
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
I am using java library for this and how can i get in this case the number
of messages?
Thanks
Emile Joubert-2 wrote:
>
> Hi cheepu,
>
> Op 22/03/2011 09:01, het cheepu geskryf:
>>
>> Hi
>> I am checking the number of message in the queue.
>> I am using the fillowing code for this.
>>
>> channel.exchangeDeclare("exchange", "direct",true);
>>
>> queuemessageSize=channel.queueDeclarePassive("queue").getMessageCount();
>>
>> I am using the same connection object. but the channel for both task is
>> different.
>>
>> I started two thread( consumer thread to consume msg from queue and a
>> thread
>> to check no of message in queue) which are running continuously but I can
>> pause and stop the consumer thread.
>> I did the following steps:
>> 1. Produced 20 message
>> Result: queue depth is 0 because all the messages are consumed by the
>> consumer thread
>> This is expected result.
>> 2. Next I paused the consumer thread. and then again produced 20 message.
>> Result: queue depth is 0( This is unexpected because there are 20
>> messages
>> in queue) and message is not consumed by the consumer thread( because
>> they
>> are paused ).
>>
>> 3. Next I stopped the consumer:
>> Result: Now I am getting the no of message in the queue ie 20.
>>
>> Question:
>> Why when the consumer is sleeping then my queue size ( ie message in
>> queue)
>> is zero?
>
> This could happen if you are using the QueueingConsumer in auto-ack
> mode, because the the QueueingConsumer will accept messages from the
> broker and store them in memory on the client. You don't say exactly
> what the consumer thread does - if it just dequeues messages from the
> QueueingConsumer then that is a possible explanation for your
> observations.
>
> You can use the following command before and after each of your 3 steps
> to confirm:
>
> rabbitmqctl list_queues name messages messages_ready
> messages_unacknowledged
>
>
> Regards
>
> Emile
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
--
View this message in context: http://old.nabble.com/checking-no-of-message-in-queue-tp31208079p31208529.html
Sent from the RabbitMQ mailing list archive at Nabble.com.
More information about the rabbitmq-discuss
mailing list