This chapter is an outline. The curriculum, learning objectives and
structure are settled; the prose, diagrams and code are still being written.
What is below is the plan for the chapter, not the chapter.
Lab 14 — Implement idempotency
Goal
Deliberately deliver the same message twice and prove the effect happened once.
Setup
To be written — CLI commands and an IaC equivalent for every resource, all prefixed sqs-course-.
Steps
- Write a consumer that increments a counter — deliberately non-idempotent
- Force a redelivery (as in Lab 04); observe the counter double-counted
- Add an idempotency table keyed on a business id
- Commit the effect and the idempotency record in one transaction
- Force the redelivery again; observe the second attempt short-circuits
- Now split them into two transactions and force a crash between — observe the hole reopen
- Add a TTL and verify it exceeds
maxReceiveCount × visibilityTimeout
What you should observe
- Two transactions is not the same as one
- The guard must key on something from the message
- A too-short TTL lets late duplicates through
Why it happened
To be written — ties each observation back to the mechanism in 09 — Delivery Semantics and Idempotency.
Experiments to try
To be written — deliberate variations that change the outcome.
Teardown
To be written — every resource created above, in dependency order.
← Back to: 29 — Hands-on Labs