[SES-PHASE-1-4] - PLU-744: add consumer for sqs events#1630
Merged
Conversation
This was referenced May 19, 2026
Contributor
Author
This was referenced May 19, 2026
66e7e1a to
7fa6e51
Compare
75e68cc to
382a321
Compare
7fa6e51 to
901af9b
Compare
382a321 to
899d39c
Compare
ogp-weeloong
left a comment
Contributor
There was a problem hiding this comment.
no need extra queue here
899d39c to
5e6000c
Compare
ogp-weeloong
reviewed
Jun 2, 2026
ogp-weeloong
reviewed
Jun 2, 2026
ogp-weeloong
reviewed
Jun 2, 2026
ogp-weeloong
reviewed
Jun 2, 2026
5e6000c to
bea7df4
Compare
b0fd3f3 to
3fddfc4
Compare
bea7df4 to
f68ee3e
Compare
3fddfc4 to
59cbb20
Compare
f68ee3e to
d0a0ee3
Compare
8c50986 to
95b7b1c
Compare
d0a0ee3 to
3a2ce7a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an SQS-backed SES event consumer to the backend worker process, enabling the worker to long-poll an SES SNS→SQS queue and dispatch parsed SES events to the existing processSesEvent handler with structured logging and graceful shutdown behavior.
Changes:
- Start an SES SQS consumer from the worker entrypoint when
SQS_QUEUE_URLis configured. - Add
ses-consumer.tsimplementing thesqs-consumerwiring, poison-message handling, and SIGTERM shutdown. - Add config + unit tests for the new consumer and introduce required SQS dependencies.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/backend/src/worker.ts | Starts the SES SQS consumer when the worker boots. |
| packages/backend/src/helpers/ses-consumer.ts | Implements SQS long-polling consumer, parsing, dispatch, logging, and SIGTERM shutdown. |
| packages/backend/src/helpers/tests/ses-consumer.test.ts | Unit tests for consumer start/stop/idempotency, poison-message handling, and SIGTERM flow. |
| packages/backend/src/config/app.ts | Adds ses.sqsQueueUrl sourced from SQS_QUEUE_URL. |
| packages/backend/package.json | Adds @aws-sdk/client-sqs and sqs-consumer dependencies. |
| package-lock.json | Locks new dependency tree for SQS consumer support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
95b7b1c to
cdaa0e1
Compare
3a2ce7a to
d760c96
Compare
cdaa0e1 to
79a7684
Compare
1bbf41b to
32c4d9d
Compare
Base automatically changed from
feat/ses/add-parser-and-worker-processor
to
feat/ses/trunk
June 8, 2026 16:01
32c4d9d to
fae6822
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

TL;DR
Adds an SQS-backed consumer for processing SES email events (bounces, complaints, etc.) directly in the worker process using
sqs-consumer.What changed?
@aws-sdk/client-sqsandsqs-consumeras dependencies.ses-consumer.ts, which creates an SQS long-polling consumer viaConsumer.createwith a batch size of 10 and a 20-second wait time. Messages are parsed via the existingparseSqsMessagehelper and dispatched toprocessSesEvent.handleMessagesignalssqs-consumerto delete (ack) it; throwing propagates the error so SQS redelivers the message according to the queue'sMaxReceiveCount.errorandprocessing_errorevents.SIGTERMlistener that callsconsumer.stop()and awaits thestoppedevent before logging completion.pollingCompleteWaitTimeMscaps the internal wait, so no external timeout race is needed.startSesConsumeris idempotent — repeated calls after the consumer is already running are no-ops.sqsQueueUrlto the app config, sourced from theSQS_QUEUE_URLenvironment variable. If unset, the consumer does not start and logs an informational message.startSesConsumerin the main worker entrypoint (worker.ts).How to test?
SQS_QUEUE_URLto a valid AWS SQS queue URL in your environment.SES consumer startedappears.processSesEventis invoked and the message is deleted from the queue.bounce@simulator.amazonses.comand it should go to the SQS queue and verifyprocessSesEventis invoked and the message is deleted from the queue.SQS_QUEUE_URLand confirm the consumer does not start and logsSQS_QUEUE_URL not set.Why make this change?
SES delivers email event notifications (bounces, complaints, deliveries) via SNS→SQS. This consumer reliably ingests those events directly in the worker process with structured error handling and graceful shutdown, rather than requiring an additional BullMQ queue layer for this use case.