Created
April 21, 2015 13:20
-
-
Save maracuja/bd0744141cfd32a5efd6 to your computer and use it in GitHub Desktop.
SQS Playing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://boto.readthedocs.org/en/latest/sqs_tut.html | |
# my aws settings | |
AWS_ACCESS_KEY_ID='' | |
AWS_SECRET_ACCESS_KEY='' | |
# creating my example queue | |
import boto.sqs | |
conn = boto.sqs.connect_to_region("eu-west-1", aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY) | |
q = conn.create_queue('david-test') | |
q.get_timeout() | |
conn.get_all_queues() | |
conn.get_queue('david-test') | |
# adding a message to the queue | |
from boto.sqs.message import Message | |
m = Message() | |
m.set_body('This is my first message.') | |
q.write(m) | |
# get my message out of the queue | |
rs = q.get_messages() | |
rm = rs[0] | |
rm.get_body() | |
# tidied up after myself | |
q.delete_message(rm) | |
conn.delete_queue(q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment