ita-social-projects / OoS-Backend

Out of School: The platform for choosing an extracurricular activity for your children

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement Transactional Outbox Pattern with SendGrid Email Sender and Quartz Job Scheduling

DmyMi opened this issue · comments

Description

As part of ongoing efforts to ensure the reliability of our email sending functionality, we need to implement the transactional outbox pattern.

Requirements

  1. Transactional Outbox Implementation: Integrate the transactional outbox pattern as described in Microservices.io - Transactional Outbox. The implementation should capture outgoing email messages in a database outbox as part of the same transaction as the business operation.

  2. Quartz Job for Outbox Polling: Implement a Quartz job that regularly polls the transactional outbox for unsent email messages. Once an email message is found, the job should send it via SendGrid and mark it as sent in the database.

  3. Rate Limit Handling: Investigate SendGrid's API to determine if it provides information on how many emails can be sent before hitting daily limits. If such an API exists or if there's any other mechanism to retrieve this information, implement a feature in the Quartz job to postpone further email sending until the next day upon reaching the limit. This is crucial for preventing rate limit errors and ensuring all emails are sent in a timely manner.

Acceptance Criteria

  • Transactional outbox pattern is implemented and integrated with the application's database.
  • Quartz job is set up to poll the transactional outbox and send emails through SendGrid.
  • Rate limit handling is implemented, with the ability to postpone sending emails upon reaching daily limits.