Skip to content

Commit

Permalink
Handle messages with no MessageAttributes in message
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Goldberg authored and renanvieira committed Jul 9, 2020
1 parent 528d84b commit 5de026f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/phoenix_letter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ def main(args=None):

for message in received_response['Messages']:
print("Sending message to '{}'".format(args.destination))

send_response = sqs_client.send_message(QueueUrl=destination_queue_url,

if 'MessageAttributes' in message:
send_response = sqs_client.send_message(QueueUrl=destination_queue_url,
MessageBody=message['Body'],
MessageAttributes=message['MessageAttributes'])
else:
send_response = sqs_client.send_message(QueueUrl=destination_queue_url,
MessageBody=message['Body'])

print("Deleting message from '{}'".format(args.source))
sqs_client.delete_message(QueueUrl=source_queue_url,
Expand Down

0 comments on commit 5de026f

Please sign in to comment.