Skip to content

Instantly share code, notes, and snippets.

@rifki192
Created May 26, 2016 03:39
Show Gist options
  • Save rifki192/c9346ff109f3e55c0d5e6600663f019d to your computer and use it in GitHub Desktop.
Save rifki192/c9346ff109f3e55c0d5e6600663f019d to your computer and use it in GitHub Desktop.
simple python script for move queue between AWS SQS
conf = {
"sqs-access-key": "",
"sqs-secret-key": "",
"sqs-queue-src": "",
"sqs-queue-dest": "",
"sqs-region": "ap-southeast-1",
}
import boto.sqs
conn = boto.sqs.connect_to_region(
conf.get('sqs-region'),
aws_access_key_id = conf.get('sqs-access-key'),
aws_secret_access_key = conf.get('sqs-secret-key')
)
q = conn.get_queue(conf.get('sqs-queue-src'))
qto = conn.get_queue(conf.get('sqs-queue-dest'))
from boto.sqs.message import RawMessage
import time
while(True):
for m in q.get_messages():
# print '%s: %s' % (m, m.get_body())
me = RawMessage()
me.set_body(m.get_body())
retval = qto.write(me)
print 'added message %s, got retval: %s' % (me.get_body(),retval)
q.delete_message(m)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment