Behavior change in message count

255 views
Skip to first unread message

optapla...@gmail.com

unread,
Jul 18, 2017, 10:18:20 AM7/18/17
to rabbitmq-users
Hello!

I have a problem with queue message count.
I'm using the Spring Rabbit cots to get the number of messages in a RabbitMQ queue.
In version 3.6.2 of RabbitMQ, the message count result was messages ready + messages unacknowledged.
And in version 3.6.10, it seems that the messages count is only messages ready.
I didn't see anything related in the release notes.
Can you please help me understand what has changed?

Thanks in advance,
SR

Michael Klishin

unread,
Jul 18, 2017, 10:21:11 AM7/18/17
to rabbitm...@googlegroups.com
Where do you observe this count?

If it's queue.declare-ok responses, nothing has changed there in years. HTTP API had
a major revamp in 3.6.7 so something could have changed there but no one has reported this to date.

It could also be a change in Spring. 

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

optapla...@gmail.com

unread,
Jul 18, 2017, 10:35:24 AM7/18/17
to rabbitmq-users
Thank you for your quick response.

I observe this using the Spring Rabbit (org.springframework.amqp) version 1.7.2.RELEASE :
                <groupId>org.springframework.amqp</groupId>
                <artifactId>spring-rabbit</artifactId>

I'm using this code:

Properties properties = rabbitAdmin.getQueueProperties(queueName);

if (properties != null) {                  

   Integer nMessages = Integer.valueOf(properties.get(RabbitAdmin.QUEUE_MESSAGE_COUNT).toString());

   LOGGER.debug("Queue {} properties: nMessages={}", queueName, nMessages);

}



Did I miss something?


Le mardi 18 juillet 2017 16:21:11 UTC+2, Michael Klishin a écrit :
Where do you observe this count?

If it's queue.declare-ok responses, nothing has changed there in years. HTTP API had
a major revamp in 3.6.7 so something could have changed there but no one has reported this to date.

It could also be a change in Spring. 
On Tue, Jul 18, 2017 at 5:18 PM, <optapla...@gmail.com> wrote:
Hello!

I have a problem with queue message count.
I'm using the Spring Rabbit cots to get the number of messages in a RabbitMQ queue.
In version 3.6.2 of RabbitMQ, the message count result was messages ready + messages unacknowledged.
And in version 3.6.10, it seems that the messages count is only messages ready.
I didn't see anything related in the release notes.
Can you please help me understand what has changed?

Thanks in advance,
SR

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Klishin

unread,
Jul 18, 2017, 10:44:31 AM7/18/17
to rabbitm...@googlegroups.com
You can quite easily compare two different versions without using Spring AMQP:

 * Declare a queue
 * Publish 10 messages to it over the default exchange
 * Consume 3 with manual acknowledgement mode using basic.get
 * Make sure that the state of Read vs Unacknowledged is what one'd expect in the management UI and `rabbitmqctl list_queues`
 * Declare the queue with passive = true and see inspect the result

I don't recall a single change in that area in a long time and no similar reports. Without hard evidence I'm more inclined to think
that your recollection of how things worked in 3.6.2 is incorrect.

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gary Russell

unread,
Jul 18, 2017, 10:52:58 AM7/18/17
to rabbitm...@googlegroups.com
RabbitAdmin.getQueueProperties() is simply a wrapper around a passive queue declaration...

DeclareOk declareOk = channel.queueDeclarePassive(queueName);
Properties props = new Properties();
props.put(QUEUE_NAME, declareOk.getQueue());
props.put(QUEUE_MESSAGE_COUNT, declareOk.getMessageCount());
props.put(QUEUE_CONSUMER_COUNT, declareOk.getConsumerCount());
return props;

...nothing has changed there either, for years.

optapla...@gmail.com

unread,
Jul 18, 2017, 11:17:48 AM7/18/17
to rabbitmq-users
Ok, so I did a simple test with my system:

I publish 5 messages to a queue with 3 active consumers.
rabbitmqctl list_queues indicates 5 messages in the queue whereas Spring Rabbit indicates 2

Is that expected?

I will run the same test tomorrow with Rabbit 3.6.2 and Spring Rabbit 1.4.0.M1 and let you know the result.

Michael Klishin

unread,
Jul 18, 2017, 11:22:45 AM7/18/17
to rabbitm...@googlegroups.com
rabbitmqctl list_queues can display messages in Ready state, in Unacknowledged state and total.

Spring AMQP (and queue.declare-ok) only reports messages in Ready state. IIRC this is a big vague
in the spec but RabbitMQ has been doing that since 1.0.

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Klishin

unread,
Jul 18, 2017, 11:27:01 AM7/18/17
to rabbitm...@googlegroups.com
I wasn't sufficiently clear: the user can decide what columns rabbitmqctl list_queues displays.

Compare `rabbitmqctl list_queues name messages messages_ready messages_unacknowledged` to
`rabbitmqctl list_queues`, for example.

Perhaps this explains the discrepancy?

optapla...@gmail.com

unread,
Jul 19, 2017, 4:58:54 AM7/19/17
to rabbitmq-users
After running some tests with an older version of RabbitMQ, I can confirm that the behavior hasen't changed between 3.6.2 and 3.6.10.

So, is there a way to get the number of messages ready + unacknowledged using RabbitMQ Java Client ?

Michael Klishin

unread,
Jul 19, 2017, 6:29:34 AM7/19/17
to rabbitmq-users
There is using HTTP API [1] and Hop [2].

optapla...@gmail.com

unread,
Jul 19, 2017, 10:27:39 AM7/19/17
to rabbitmq-users
Ok thanks, I will take a look at it.
Reply all
Reply to author
Forward
0 new messages