Skip to content

Instantly share code, notes, and snippets.

@jconnolly
Created September 29, 2015 17:51
Show Gist options
  • Save jconnolly/3cb345b8b99abee09f34 to your computer and use it in GitHub Desktop.
Save jconnolly/3cb345b8b99abee09f34 to your computer and use it in GitHub Desktop.
# example_publisher.py
import pika, os, logging
logging.basicConfig()
url = 'amqp://guest:guest@localhost:5672/%2F'
params = pika.URLParameters(url)
params.socket_timeout = 5
connection = pika.BlockingConnection(params) # Connect to CloudAMQP
channel = connection.channel() # start a channel
channel.queue_declare(durable=True, queue='new-user-confirm-email') # Declare a queue
# send a message
channel.basic_publish(exchange='event', routing_key='new.user', body='{"email":"jeconnol@gmail.com"}')
print " [x] Message sent to consumer"
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment