Created
May 29, 2019 14:46
-
-
Save patrickpierson/5f74cfc86a01615d434562967876d4e4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 boto3 | |
sqs_client = boto3.client('sqs') | |
while True: | |
with open('messages.txt', 'a') as save_file: | |
messages = sqs_client.receive_message( | |
QueueUrl='https://sqs.us-east-1.amazonaws.com/1234567890123/example', | |
MaxNumberOfMessages=10 | |
) | |
for message in messages.get('Messages'): | |
save_file.write(message.get('Body') + '\n') | |
delete_response = sqs_client.delete_message( | |
QueueUrl='https://sqs.us-east-1.amazonaws.com/1234567890123/example', | |
ReceiptHandle=message.get('ReceiptHandle') | |
) | |
print('Processed %s messages' % len(messages.get('Messages'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment