in code/lab-2/generic-backend-microservice/app.py [0:0]
def process(event):
print('{} process: {}'.format(SERVICE_NAME, event))
message_id = event['id']
# will fail randomly to show the Amazon SNS redelivery feature
if random.choice([True, False]):
print("--------------------------------------")
print("{{'msg-id': '{}', 'status': 'FAILED'}}".format(message_id))
print("--------------------------------------")
raise Exception("I'm failing randomly...")
print("+++++++++++++++++++++++++++++++++++++++++")
print("{{'msg-id': '{}', 'status': 'PROCESSED'}}".format(message_id))
print("+++++++++++++++++++++++++++++++++++++++++")