Hi,
I am new to rabbitMQ. I am using python pika module to communicate
with rabbitMQ server.
is there a function in pika to tell if the message queue is empty or
not??

Thanks,
Vinod

Search Discussions

  • Gavin M. Roy at Jul 6, 2011 at 2:34 am
    You can do a queue.declare('queue_name', passive=True) and get the results of that which will have the queue depth.
    On Tuesday, July 5, 2011 at 9:05 PM, Vinod Sharma wrote:

    Hi,
    I am new to rabbitMQ. I am using python pika module to communicate
    with rabbitMQ server.
    is there a function in pika to tell if the message queue is empty or
    not??

    Thanks,
    Vinod
    _______________________________________________
    rabbitmq-discuss mailing list
    rabbitmq-discuss at lists.rabbitmq.com (mailto:rabbitmq-discuss at lists.rabbitmq.com)
    https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
  • Vinod sharma at Jul 6, 2011 at 2:38 am
    Thanks Gavin for the response. I already got the answer but was not able to
    post the message.
    Here is what i did:Similar to what you have suggested.

    status = channel.queue_declare(queue=msgqueue)
    if status.method.message_count == 0:
    print "queue empty"

    On Tue, Jul 5, 2011 at 7:34 PM, Gavin M. Roy wrote:

    You can do a queue.declare('queue_name', passive=True) and get the results
    of that which will have the queue depth.
    On Tuesday, July 5, 2011 at 9:05 PM, Vinod Sharma wrote:

    Hi,
    I am new to rabbitMQ. I am using python pika module to communicate
    with rabbitMQ server.
    is there a function in pika to tell if the message queue is empty or
    not??

    Thanks,
    Vinod
    _______________________________________________
    rabbitmq-discuss mailing list
    rabbitmq-discuss at lists.rabbitmq.com (mailto:
    rabbitmq-discuss at lists.rabbitmq.com)
    https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

    --
    Regards,
    --------------------------------
    Vinod Sharma
    http://securitygyan.com
    McAfee Inc
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110705/6b967551/attachment.htm>
  • Mark K at Sep 21, 2011 at 2:30 pm
    Gavin M. Roy <gmr at ...> writes:
    You can do a queue.declare('queue_name', passive=True) and get the results of
    that which will have the
    queue depth.
    On Tuesday, July 5, 2011 at 9:05 PM, Vinod Sharma wrote:

    Hi,
    I am new to rabbitMQ. I am using python pika module to communicate
    with rabbitMQ server.
    is there a function in pika to tell if the message queue is empty or
    not??

    Thanks,
    Vinod
    _______________________________________________
    rabbitmq-discuss mailing list
    rabbitmq-discuss at ... (mailto:rabbitmq-discuss at ...)
    https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

    THank you for the example. I noticed one thing.... the
    status.method.message_count doesn't always match the number in the queue. For
    example I have a situation now where there is one message in the queue, and I
    can get an accurate count using the Rabbitmq api/queues but the status.method
    reports no messages in the same queue.
  • Matthias Radestock at Sep 21, 2011 at 2:44 pm
    Mark,
    On 21/09/11 15:30, Mark K wrote:
    I noticed one thing.... the
    status.method.message_count doesn't always match the number in the queue. For
    example I have a situation now where there is one message in the queue, and I
    can get an accurate count using the Rabbitmq api/queues but the status.method
    reports no messages in the same queue.
    That's because queue.declare et al return
    <quote>
    [The] number of messages present in the queue [...] that are not
    awaiting acknowledgement.
    </quote>
    (from the AMQP 0-9-1 spec xml)

    whereas the 'messages' figure in rabbitmqctl and management includes
    messages awaiting acknowledgement. You can get a breakdown with, e.g.,
    rabbitmqctl list_queues name messages_ready messages_unacknowledged
    The messages_ready count should correspond to the count returned by the
    AMQP commands.

    Matthias.
  • Mark K at Sep 21, 2011 at 3:13 pm
    Thanks. That makes sense.
    Mark
  • Mark K at Sep 21, 2011 at 5:35 pm
    Mark K <mkovachmcse at ...> writes:
    Thanks. That makes sense.
    Mark
    An additional question: I want to be able to spin up and down consumers as
    needed, depening on the number messages in the queue. My thought is to do this
    in the code that is the consumer, if no more messages then do a clean close and
    release the thread it runs in. I have it working to a point, but not great. Are
    there any examples of having the consumer close when "sees" there are no more
    messages in a queue without just killing a thread the ugly way? Or is my logic
    wrong on how to do something like this? I'm using this with Python 2.7.

    Thanks
    Mark
  • Marek Majkowski at Sep 28, 2011 at 9:56 am

    On Wed, Sep 21, 2011 at 18:35, Mark K wrote:
    An additional question: I want to be able to spin up and down consumers as
    needed, depening on the number messages in the queue. My thought is to do this
    in the code that is the consumer, if no more messages then do a clean close and
    release the thread it runs in. I have it working to a point, but not great. Are
    there any examples of having the consumer close when "sees" there are no more
    messages in a queue without just killing a thread the ugly way? Or is my logic
    wrong on how to do something like this? I'm using this with Python 2.7.
    What do you mean by "killing a thread the ugly way" ?

    Marek.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprabbitmq-discuss @
categoriesrabbitmq
postedJul 6, '11 at 1:05a
activeSep 28, '11 at 9:56a
posts8
users5
websiterabbitmq.com
irc#rabbitmq

People

Translate

site design / logo © 2017 Grokbase