Last active
August 14, 2017 05:36
-
-
Save doppiomacchiatto/a0b5ec8e1956d9b029e771199485658e 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
## get sqs messages | |
for idx, item in enumerate(response['Messages']): | |
# create list of dictionaries to process | |
self.logger.debug('idx %d', idx) | |
messages.append(json.loads(item['Body'])) | |
tmp_dict = {'Id': item['MessageId'], 'ReceiptHandle': item['ReceiptHandle']} | |
self.logger.debug('id: %s', item['MessageId']) | |
delete_list.insert(idx,tmp_dict) | |
try: | |
client = boto3.client('sqs') | |
response = client.delete_message_batch(QueueUrl=url, Entries=delete_list) | |
if response['ResponseMetadata']['HTTPStatusCode'] != 200: | |
raise Exception('the sqs delete_batch process failed') | |
self.logger.debug(response) | |
except botocore.exceptions.ClientError as error: | |
error_code = int(error.response['Error']['Code']) | |
self.logger.error("Error Code: %s", error_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment