send.py 314 B

123456789101112
  1. #!/usr/bin/env python3
  2. import pika
  3. connection = pika.BlockingConnection(pika.ConnectionParameters("localhost"))
  4. channel = connection.channel()
  5. channel.queue_declare(queue="hello")
  6. channel.basic_publish(exchange="", routing_key="hello", body="Hello World!")
  7. print(" [x] Send 'Hello World!'")
  8. connection.close()