Skip to content

Instantly share code, notes, and snippets.

@jconnolly
Last active September 29, 2015 17:50
Show Gist options
  • Save jconnolly/8dc9393e350de6f3447c to your computer and use it in GitHub Desktop.
Save jconnolly/8dc9393e350de6f3447c to your computer and use it in GitHub Desktop.
import pika, os, logging, time
logging.basicConfig()
def send_email(msg):
print msg
print "sending email"
time.sleep(5) # delays for 5 seconds
print "email sent";
return;
url = 'amqp://guest:guest@localhost:5672/%2F'
params = pika.URLParameters(url)
params.socket_timeout = 5
connection = pika.BlockingConnection(params)
channel = connection.channel() # start a channel
def callback(ch, method, properties, body):
send_email(body)
channel.basic_consume(callback,
queue='new-user-confirm-email',
no_ack=True)
# start consuming (blocks)
channel.start_consuming()
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment