Step-by-step answer
Core 75 min6 stepsSimulate leases, redelivery and fairness
A 200-line discrete-event simulation of an at-least-once queue with leases, redelivery, dead-lettering, global and per-tenant concurrency caps and idempotent or non-idempotent handlers. It shows 130 duplicate executions per 1,000 messages from a 60-second lease over a 90-second p99 (zero with renewal), small firms' p95 wait falling from 4 minutes to 6 seconds under a per-tenant cap, and the nightly sweep needing exactly the 27 consumers Little's law predicts.
Back to the exercise