An order spans two services: Fulfilment puts the bundle on the line, then Wallet takes the money. When the payment fails, the customer keeps the bundle for free, because the failure never reaches the order and nothing is undone. Trace it first, then fix it.
Advanced35 min on the clock6 graded checks · 100 pointsServices That Fail PolitelyPro
AssumesWhere the transaction endsAll or nothing inside one database, where a transaction can do it for you. A saga is what you write when the steps live in two databases and it cannot.
Graded by reading your code against the checklist below.
What you build
Fill in Trace.cs before changing any code
Correlate both faults on the order id inside the failed command
Fail the order when the grant fails
When the payment fails, revoke the bundle that was already granted
Ignore a second OrderPlaced while the order is in progress
Ignore late or duplicate messages once the order has finished
Done means
The trace is right, faults correlate on the inner message, a grant failure faults the order, a payment failure revokes the bundle, and duplicates and late arrivals are ignored.
How it is graded
Published in full, before you start — every point is one of these and there is nothing else.
The trace names the right states+10Undoing a step in another service
Both faults correlate on the inner order id+20Undoing a step in another service
A failed grant faults the order+15Undoing a step in another service
A failed payment revokes the bundle+25Undoing a step in another service
A second OrderPlaced is ignored mid-order+10Safe to repeat
Late messages are ignored after the end+20Messages arrive twice, late, or never
What it teaches
Undoing a step in another serviceadvanced
There is no transaction across two services, so a process that spans them is a series of local steps, each with a message that reverses it — and when a later step fails, you send those messages instead of rolling back.
A request that times out has not necessarily failed — you just did not hear back — so the client retries, and unless the write recognises that it has already happened the customer is charged twice.
A message broker promises to deliver at least once, not exactly once, so every consumer has to cope with a duplicate, a message that arrives after it stopped mattering, and a failure that waiting will never fix.