Page MenuHomeDevCentral
Paste P256

Count queue messages with Pika

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

Event Timeline

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.