You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
823 B

from __future__ import print_function
import sys
import pika
from sylvilagus.ch02 import hello_world
def msg_consumer(channel, method, header, body):
channel.basic_ack(delivery_tag=method.delivery_tag)
if body == 'quit':
channel.basic_cancel(consumer_tag='hello-consumer')
channel.stop_consuming()
else:
print(body)
return
def main():
channel = hello_world.get_channel()
channel.queue_declare(queue='hello-queue')
channel.queue_bind(queue='hello-queue',
exchange='hello-exchange',
routing_key='hola')
channel.basic_consume(msg_consumer,
queue='hello-queue',
consumer_tag='hello-consumer')
print('consuming...')
channel.start_consuming()
return 0
if __name__ == '__main__':
sys.exit(main())