Using RabbitMQ is there a way to look at the queue contents without a dequeue operation?

前端 未结 3 1402
花落未央
花落未央 2020-12-13 23:49

As a way to learn RabbitMQ and python I\'m working on a project that allows me to distribute h264 encodes between a number of computers. The basics are done, I have a daemo

3条回答
  •  旧巷少年郎
    2020-12-14 00:14

    @MichaelDillon based on your answer to make others life easier I am putting here a no_ack example:

    #!/usr/bin/env python
    import pika
    
    connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
    channel = connection.channel()
    
    channel.queue_declare(queue='Q.hello')
    
    
    def callback(ch, method, properties, body):
        print(" [x] Received %r" % body)
        # ch.basic_ack(delivery_tag=method.delivery_tag)
    
    channel.basic_consume(callback, queue='Q.hello')
    
    print(' [*] Waiting for messages. To exit press CTRL+C')
    channel.start_consuming()
    

提交回复
热议问题