Skip to content

Instantly share code, notes, and snippets.

@yuta-imai
Last active December 15, 2015 04:39
Show Gist options
  • Save yuta-imai/5202898 to your computer and use it in GitHub Desktop.
Save yuta-imai/5202898 to your computer and use it in GitHub Desktop.
import json
import time
import boto
import boto.sqs
import boto.sns
sns_cn = boto.sns.connect_to_region('ap-northeast-1')
sqs_cn = boto.sqs.connect_to_region('ap-northeast-1')
q = sqs_cn.get_queue('QUEUE_NAME')
counter = 0
while counter < 10:
sns_cn.publish('SNS_ARN',json.dumps({'via':'sns','id':counter}))
counter += 1
time.sleep(5)
while 1:
messages = q.get_messages(10)
if len(messages) == 0:
break
for message in messages:
print message.get_body()
sqs_cn.delete_message(q,message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment