[rabbitmq-discuss] checking no of message in queue

cheepu shammi at arosys.com
Tue Mar 22 09:01:50 GMT 2011


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?
I want the queue size at the time when the consumer in the paused state.
What wrong I am doing and what should I do? 


Thanks
	
	
-- 
View this message in context: http://old.nabble.com/checking-no-of-message-in-queue-tp31208079p31208079.html
Sent from the RabbitMQ mailing list archive at Nabble.com.



More information about the rabbitmq-discuss mailing list