Last active
December 15, 2015 04:39
-
-
Save yuta-imai/5202898 to your computer and use it in GitHub Desktop.
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
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