in qldb_streaming_sample/app.py [0:0]
def send_sns_notification(topic_arn, message):
"""
Sends SNS notification to topic_arn.
Retries once for Retryable Errors.
Parameters:
topic_arn (string): The topic you want to publish to.
message (string): The message you want to send.
"""
for _ in range(0, 2):
try:
sns_client.publish(
TopicArn=topic_arn,
Message=message
)
print("SNS published to topic : " + topic_arn + " with message : " + message)
break
except ClientError as e: # https://docs.aws.amazon.com/sns/latest/api/CommonErrors.html
if e.response['Error']['Code'] in RETRYABLE_ERRORS:
print("Caught retryable error : ", e)
pass
else:
# Non retryable error
print("Caught non retryable error : ", e)
break