product.py
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters("localhost"))
channel = connection.channel()
channel.queue_declare(queue="hello")
channel.basic_publish(exchange="",routing_key="hello",body="Hello WOrld")
print("[x] Send 'Hello World'")
connection.close()
cousumer.py
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
def callable(ch, method, properties, body):
print("[x] Received %r" % body)
channel.basic_consume(callable,
queue='hello',
no_ack=True)
print(' [*] Waiting for messages')
channel.start_consuming()