[rabbitmq-discuss] Is it possible to retrieve the number of unacked messages on a queue?

Peter Soukalopoulos peter at greenbutton.com
Fri Jun 7 03:28:10 BST 2013


Found the solution using the RabbitMQ Management HTTP API
/api/queues/%F/queue which returns a JSON response including values for
messages_ready, messages_unacknowledged and messages.



{

    "memory": 18104,

   "idle_since": "2013-06-05 21:42:17",

    "exclusive_consumer_tag": "",

    "messages_ready": 2,

    "messages_unacknowledged": 0,

    "messages": 2,

    "consumers": 0,

    "slave_nodes": [],

    "backing_queue_status": {

        "q1": 0,

        "q2": 0,

        "delta": [

            "delta",

            "undefined",

            0,

            "undefined"

        ],

*..stuff deleted*

}



See
http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html



*Regards,*

*Peter*



*Peter** **Soukalopoulos*
*Development Team Leader | **GreenButton Limited *| www.greenbutton.com
Level 2, James Smith Building, 55 Cuba Street, Wellington, New Zealand
Mobile: +64 22 632 5023| DDI: +644 974 6602 |
peter.soukalopoulos at greenbutton.com | Skype: psoukal | HQ: +644 499 0424

[image: Description: GreenButton_words_small]               [image:
cid:image003.jpg at 01CC4E01.BA075BC0]

For best support, please respond to help at greenbutton.com and retain the
ticket number in the subject line.



This message contains confidential information, intended only for
the person(s) named above, which may also be privileged. Any use,
distribution, copying or disclosure by any other person is strictly
prohibited. In such case, you should delete this message and kindly notify
the sender via reply e-mail. Please advise immediately if you or your
employer does not consent to Internet e-mail for messages of this kind.



*From:* Peter Soukalopoulos [mailto:peter at greenbutton.com]
*Sent:* Friday, 7 June 2013 10:16 a.m.
*To:* 'rabbitmq-discuss at lists.rabbitmq.com'
*Subject:* Is it possible to retrieve the number of unacked messages on a
queue?



I’ve done a little searching via Google to retrieve the number of Unacked
messages via the RabbitMQ client API. Most threads say it’s not possible.



Does anyone have an explanation or, even better, a solution?



FYI I’m using C# .Net – this code returns the number of Ready messages.



        public int GetApproximateCount(string queueName)

        {

            using (var connection = CreateConnection())

            using (var model = connection.CreateModel())

            {

                try

                {

                    var result = model.QueueDeclarePassive(queueName);

                    return (int)result.MessageCount;

                }

                catch (OperationInterruptedException)

                {

                    return 0;

                }

            }

        }



*Regards,*

*Peter*



*Peter** **Soukalopoulos*
*Development Team Leader | **GreenButton Limited *| www.greenbutton.com
Level 2, James Smith Building, 55 Cuba Street, Wellington, New Zealand
Mobile: +64 22 632 5023| DDI: +644 974 6602 |
peter.soukalopoulos at greenbutton.com | Skype: psoukal | HQ: +644 499 0424

[image: Description: GreenButton_words_small]               [image:
cid:image003.jpg at 01CC4E01.BA075BC0]

For best support, please respond to help at greenbutton.com and retain the
ticket number in the subject line.



This message contains confidential information, intended only for
the person(s) named above, which may also be privileged. Any use,
distribution, copying or disclosure by any other person is strictly
prohibited. In such case, you should delete this message and kindly notify
the sender via reply e-mail. Please advise immediately if you or your
employer does not consent to Internet e-mail for messages of this kind.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130607/e0549b31/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 7433 bytes
Desc: not available
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130607/e0549b31/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 3761 bytes
Desc: not available
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130607/e0549b31/attachment.jpeg>


More information about the rabbitmq-discuss mailing list