Created
August 31, 2017 23:32
-
-
Save arkilis/5d73b47ff55bf95545db520a5cd43fe2 to your computer and use it in GitHub Desktop.
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
import pika | |
def on_message(channel, method_frame, header_frame, body): | |
channel.basic_ack(delivery_tag=method_frame.delivery_tag) | |
print body | |
parameters = pika.URLParameters('amqp://guest:guest@localhost:5672/%2F') | |
connection = pika.BlockingConnection(parameters) | |
channel = connection.channel() | |
channel.exchange_declare(exchange='web_develop', exchange_type='direct', | |
passive=False, durable=True, auto_delete=False) | |
channel.queue_declare(queue='standard', auto_delete=True) | |
channel.queue_bind(queue='standard', exchange='web_develop', | |
routing_key='xxx_routing_key') | |
channel.basic_consume(on_message, 'standard') | |
try: | |
channel.start_consuming() | |
except KeyboardInterrupt: | |
channel.stop_consuming() | |
connection.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment