MessageCount in Thread #1210
-
Hello everyone, I have tried to get the number of messages in the queue from the handler(Thread) but it always returns 0. From the main thread it returns the amount. I need to be able to know how many messages are left in the queue at any given time. Thanks for the help |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You haven't provided a lot of detail on what exactly you did. If you did a passive queue declare, then it only will count messages in Ready state. So if you try one message at a time, or use automatic acknowledgement mode, those will typically be zero by the time your consumer handler is invoked. |
Beta Was this translation helpful? Give feedback.
-
Hi, I am having the same issue with RabbitMQ Client version 6.5.0 downloaded from nupkg. My project is composed of a few containers which communicate each other through an event bus amqp-based (RabbitMQ). The first container A is multithread working only as producer (it has a single shared connection among threads and one channel per thread). I downloaded the source code from github here and ran quite a few tests. Please let me know if further information is needed. Thanks |
Beta Was this translation helpful? Give feedback.
You haven't provided a lot of detail on what exactly you did. If you did a passive queue declare, then it only will count messages in Ready state. So if you try one message at a time, or use automatic acknowledgement mode, those will typically be zero by the time your consumer handler is invoked.