Skip to content

Commit

Permalink
23413 put the email msg back on the queue if notify-api fails (#2992)
Browse files Browse the repository at this point in the history
  • Loading branch information
vysakh-menon-aot authored Sep 19, 2024
1 parent a741bd1 commit d68da88
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions queue_services/entity-emailer/src/entity_emailer/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,18 @@ def send_email(email: dict, token: str):
logger.debug('Send email: email object(s) is missing')
raise QueueException('Unsuccessful sending email - required email object(s) is missing. ')

resp = requests.post(
f'{APP_CONFIG.NOTIFY_API_URL}',
json=email,
headers={
'Content-Type': 'application/json',
'Authorization': f'Bearer {token}'
}
)
if resp.status_code != HTTPStatus.OK:
try:
resp = requests.post(
f'{APP_CONFIG.NOTIFY_API_URL}',
json=email,
headers={
'Content-Type': 'application/json',
'Authorization': f'Bearer {token}'
}
)
if resp.status_code != HTTPStatus.OK:
raise EmailException
except Exception: # noqa B902; pylint: disable=W0703; we don't want to fail out the email, so ignore all.
# this should log the error and put the email msg back on the queue
raise EmailException('Unsuccessful response when sending email.')

Expand Down

0 comments on commit d68da88

Please sign in to comment.