you cannot get messages count using the SDK. channel.queueDeclarePassive(queueName).getMessageCount() is usually not correct because it won't count messages which waiting acknowledges.
you can enable the management plugin and query the queue by REST API:
http://localhost:15672/api/queues/vhost/queue_name
The response contains the total messages count as well as messages in handling/ready state. Access to "localhost:15672/api" to see more detail about how to call it.
Here is an example response of it on local server:
{
"memory":14680,
"message_stats":{
"publish":1,
"publish_details":{
"rate":0
}
},
"messages":1,
"messages_details":{
"rate":0
},
"messages_ready":1,
"messages_r