[rabbitmq-discuss] problem on queue depth checking?

sameekmishra sameek at arosys.com
Tue Mar 13 13:01:13 GMT 2012


Hi All,

I am running a thread for checking the depth of queue(i.e. no of messages in
queue), and one thread to consume the message.
Both the threads are running infinitely.
in both the thread the common object is mq connection object. In both thread
i am creating seperate channel and binding them with same queue.
Consumer thread consumes message if available and then sleep for 1
minutes(This scenario is for testing only).
Queue Depth checking thread checks the queuedepth and then sleep for 10
seconds.
Now if i publish 2 messages then one message will be consumed(and thread
will sleep for one minute) and one will be in the queue;
And queue depth checking thread must show the queuedepth = 1. But I am
getting the queuedepth 0.
But if we dont consume the message from queue then queuedepth is shown
correctly. 

I observed that the below code creating separte channel and both are reading
same queue. may that is the reason it show queuedeptha wrong.

used consumer code:

		channel = connection.createChannel();
                channel.exchangeDeclare(requestExchangeName, exchangeType,
durable);
                channel.queueDeclare(requestQueueName, durable, false,
false, null);
                channel.queueBind(requestQueueName, requestExchangeName,
requestRoutingKey);
                consumer = new QueueingConsumer(channel);
                channel.basicConsume(requestQueueName, noAck, consumer);

used queueDepth code:

                channel = connection.createChannel();
		DeclareOk queueDeclarePassive = channel.queueDeclarePassive(queueName);
                queueDepth=  queueDeclarePassive.getMessageCount();
                

please help me to figure out the problem and solution as well.
-- 
View this message in context: http://old.nabble.com/problem-on-queue-depth-checking--tp33494003p33494003.html
Sent from the RabbitMQ mailing list archive at Nabble.com.



More information about the rabbitmq-discuss mailing list