receive.py 476 B

12345678910111213141516171819
  1. #!/usr/bin/env python3
  2. import pika
  3. # https://www.rabbitmq.com/tutorials/tutorial-one-python.html
  4. connection = pika.BlockingConnection(pika.ConnectionParameters('rabbitmq'))
  5. channel = connection.channel()
  6. channel.queue_declare(queue='hello')
  7. def callback(ch, method, properties, body):
  8. print(body.decode('utf-8'))
  9. connection.close()
  10. channel.basic_consume(callback,
  11. queue='hello',
  12. no_ack=True)
  13. channel.start_consuming()