This commit is contained in:
2026-04-03 17:03:14 -05:00
parent 27c2be664a
commit bed6c2a398

View File

@@ -53,7 +53,6 @@ def get_queue_url(domain):
raise
def publish_to_sns(topic_arn, message_body, msg_id):
"""Versucht SNS Publish. Gibt True bei Erfolg, False bei Topic-Not-Found."""
attempt = 0
while attempt < MAX_RETRIES:
try:
@@ -65,8 +64,9 @@ def publish_to_sns(topic_arn, message_body, msg_id):
return True
except ClientError as e:
error_code = e.response['Error']['Code']
if error_code == 'NotFound' or error_code == 'NotFoundException':
logger.info(f" SNS Topic not found for {topic_arn} — falling back to SQS")
# Fallback auf SQS bei Topic-nicht-gefunden ODER fehlender Berechtigung
if error_code in ('NotFound', 'NotFoundException', 'AuthorizationError'):
logger.info(f" SNS unavailable for {topic_arn} ({error_code}) — falling back to SQS")
return False
attempt += 1
logger.warning(f"Retry {attempt}/{MAX_RETRIES} SNS: {error_code}")