Decouple admission, processing and delivery
Choose a queue, event bus or orchestrator and define what happens when a consumer repeats work.
Task 2.1 · Decouple admission, processing and delivery
Locate the handoff
A synchronous web request couples the caller to every downstream dependency. For work the customer can collect later, use API Gateway or an ALB to admit the request, persist a job identifier and place work on SQS. Return an acknowledgement only after a durable handoff. Independent workers scale on backlog per worker and age of the oldest message. Keep state in shared storage so replacement tasks can resume. Lambda suits short bounded events. Long-lived or specially packaged workers can run as ECS tasks on Fargate or in EKS where Kubernetes APIs are required.
Choose delivery semantics
A standard SQS queue distributes work among competing consumers. It can deliver more than once. Set visibility long enough for normal processing, extend it for legitimate long jobs, and delete after the durable outcome. Make side effects idempotent with a stable business identifier and a conditional write or a downstream idempotency key. A dead-letter queue preserves recurring failures for repair. FIFO message groups preserve order within each group. Multiple groups enable parallel consumption.
Fan out or coordinate
SNS with one queue per subscriber lets billing and email each receive an order while tolerating different outages. EventBridge routes by event attributes across producers and targets. Step Functions records progress and coordinates retries, waits and compensation when later work depends on earlier results. An ALB can route independent services by path, a cache or CDN can serve repeated reads, and read replicas can absorb tolerant reporting traffic. For legacy SFTP clients, Transfer Family can land a file in S3 and start a separate processing path.
Set a migration boundary for messaging
If an existing RabbitMQ or ActiveMQ application depends on its protocol and broker features, evaluate Amazon MQ and test client compatibility before changing the contract. When clients can change, SQS offers a simpler work queue, while SNS distributes separate copies to subscribers. A reporting view can consume durable change events and maintain its own projection. Give consumers independent checkpoints, a lag target and a way to rebuild that view after a schema change.
An invoice is issued twice
A worker calls the billing provider successfully, then stops before deleting its queue message. A second worker receives the same order. Increasing visibility has reduced duplicate frequency but bills still appear twice.
Where should the deduplication identity live, and when should the worker acknowledge the message?
Compare your design with the worked answer
Persist an order-specific idempotency key and use that same key when invoking a provider that supports it. On redelivery, reconcile the recorded outcome or ask the provider for the existing result. Delete after recording success. A local flag set before an external side effect cannot by itself prove that the provider completed it.
If every department also needs an independent copy, add one queue per department behind SNS. Adding competing consumers to the original queue divides messages among them.
Apply the video example
Use a two-worker timeline for the visibility example. Put receipt at second 0, successful external processing at second 38 and deletion at second 40. With 30 seconds of visibility, a second worker can receive the same job before the first finishes. Move the lease and add an idempotency check as separate corrections.
freeCodeCamp at 28:39:51 · SQS visibility timeout
AWS exam guide for this domain · Return to the objective map
Decouple admission, processing and delivery quiz
Answer 5 questions. Check each answer for an explanation.