Page MenuHomeDevCentral
Paste P256

Count queue messages with Pika
ActivePublic

Authored by dereckson on Jul 5 2017, 22:35.
def count_queue_messages(queue_name):
connection = get_broker_connection(service['config'])
channel = connection.channel()
result = channel.queue_declare(durable=True,
queue=queue_name,
passive=True)
return result.method.message_count
def is_queue_empty(queue_name):
return count_queue_messages(queue_name) == 0

Event Timeline

dereckson created this paste.Jul 5 2017, 22:35
dereckson added a project: Message queues.
dereckson changed the title of this paste from Count queue messages in a broker to Count queue messages with Pika.