Skip to content

Instantly share code, notes, and snippets.

@nazarsa
Created November 15, 2016 16:20
Show Gist options
  • Save nazarsa/dfd35bce4c7a950a1e1c8132ac3e9661 to your computer and use it in GitHub Desktop.
Save nazarsa/dfd35bce4c7a950a1e1c8132ac3e9661 to your computer and use it in GitHub Desktop.
Rabbit MQ Receive Message Python Script
#!/usr/bin/env python
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='queuename')
def callback(ch, method, properties, body):
print(" [x] Received %r" % body)
channel.basic_consume(callback,
queue='queuename',
no_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment