Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import pika
- import time
- connection = pika.BlockingConnection(pika.ConnectionParameters(
- host='localhost'))
- channel = connection.channel()
- channel.exchange_declare(exchange='tasks', type='direct')
- channel.queue_declare(queue='task_queue', durable=True)
- print ' [*] Waiting for messages. To exit press CTRL+C'
- def callback(ch, method, properties, body):
- print " [x] Received %r" % (body,)
- time.sleep( body.count('.') )
- print " [x] Done"
- ch.basic_ack(delivery_tag = method.delivery_tag)
- channel.basic_qos(prefetch_count=1)
- channel.queue_bind(exchange='tasks', queue='task_queue', routing_key='task_queue')
- channel.basic_consume(callback,
- queue='task_queue')
- channel.start_consuming()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement