Skip to content

Instantly share code, notes, and snippets.

@tomas-stefano
Created August 20, 2011 03:52
Show Gist options
  • Select an option

  • Save tomas-stefano/1158626 to your computer and use it in GitHub Desktop.

Select an option

Save tomas-stefano/1158626 to your computer and use it in GitHub Desktop.
RabbitMQ example in python
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
def callback(ch, method, properties, body):
"""docstring for callback"""
print "[x] Received: %r" % (body,)
channel.basic_consume(callback, queue='hello', no_ack=True)
channel.start_consuming()
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='', routing_key='hello', body='Hello World!')
print "[x] Sent! Hello Word!"
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment