Skip to content

Commit a6cef58

Browse files
authored
Merge pull request #1868 from bcgov/dev
Dev
2 parents 9e288d1 + 7ba7481 commit a6cef58

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

  • applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Application/Integrations/RabbitMQ

applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Application/Integrations/RabbitMQ/EmailConsumer.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,38 @@ private async Task ProcessEmailAsync(
128128
{
129129
await SaveEmailLogWithRetryAsync(emailLog, uow);
130130
}
131+
catch (Exception ex)
132+
{
133+
logger.LogError(
134+
ex,
135+
"Email sending failed for Email {EmailId}. Tenant {TenantId}. Marking as failure and retrying.",
136+
emailLog.Id,
137+
notificationEvent.TenantId
138+
);
139+
140+
emailLog.Status = EmailStatus.Failed;
141+
await HandleRetryAsync(emailLog, notificationEvent, uow);
142+
return;
143+
}
144+
145+
UpdateEmailLogStatus(emailLog, response);
146+
147+
if (ShouldRetry(response.StatusCode))
148+
{
149+
await HandleRetryAsync(emailLog, notificationEvent, uow);
150+
}
151+
else
152+
{
153+
await SaveEmailLogWithRetryAsync(emailLog, uow);
154+
}
155+
}
156+
catch (Exception ex)
157+
{
158+
logger.LogError(
159+
ex,
160+
"Unexpected processing error for Email {EmailId}.",
161+
emailLog.Id
162+
);
131163
}
132164
catch (Exception ex)
133165
{

0 commit comments

Comments
 (0)