Advertisement
Guest User

Untitled

a guest
Jun 5th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import pika
  3. import sys
  4.  
  5. connection = pika.BlockingConnection(pika.ConnectionParameters(
  6.         host='localhost'))
  7. channel = connection.channel()
  8.  
  9. channel.exchange_declare(exchange='tasks', type='direct')
  10. channel.queue_declare(queue='task_queue', durable=True)
  11.  
  12. message = ' '.join(sys.argv[1:]) or "Hello World!"
  13. channel.basic_publish(exchange='tasks',
  14.                       routing_key='task_queue',
  15.                       body=message,
  16.                       properties=pika.BasicProperties(
  17.                          delivery_mode = 2, # make message persistent
  18.                       ))
  19. print " [x] Sent %r" % (message,)
  20. connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement