Created
November 15, 2016 16:20
-
-
Save nazarsa/dfd35bce4c7a950a1e1c8132ac3e9661 to your computer and use it in GitHub Desktop.
Rabbit MQ Receive Message Python Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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