How can we check completion and retries when processing finishes after the request returns?
Observe a durable state transition or event rather than sleeping for an assumed processing time. Give the test control over when the worker runs and when an acknowledgement arrives.
Work through the decision
When delivery repeats, a naive worker creates a second order. A fast happy-path assertion sees only the first one.
| Step | Evidence to keep |
|---|---|
| Enqueue once | Capture the business request key. |
| Replay delivery | Keep the business key and change the delivery ID. |
| Check terminal state | Assert one stored order and the expected completion event. |
What changes the decision
Keep timeout and duplicate tests separate. A job can finish on time and still perform the business action twice.