HomeChallengesRepsProblemsLeaderboardTake a challenge

Retrying what can never succeed

An empty wallet is retried three times, fifteen seconds apart, before the order is told. A redelivered debit charges the customer twice. Retry only what waiting can fix, and make the debit safe to receive more than once.

Advanced25 min on the clock7 graded checks · 100 pointsServices That Fail PolitelyPro
Graded by reading your code against the checklist below.

What you build

  • Stop retrying InsufficientFundsException
  • Stop retrying UnknownCustomerException
  • Recognise a debit that has already been applied
  • Use the order id, not the message id, as the key
  • On a duplicate, reply again but take nothing
  • Check the balance before changing it
  • Record each order the wallet has paid for

Done means

Business failures fail once, the debit is keyed on the order id, duplicates reply without charging, and the balance is checked first.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. An empty wallet is not retried+15Messages arrive twice, late, or never
  2. An unknown customer is not retried+10Messages arrive twice, late, or never
  3. A debit already applied is recognised+25Safe to repeat
  4. The key is the order, not the message+10Safe to repeat
  5. A duplicate replies again, then stops+15Messages arrive twice, late, or never
  6. The balance is checked before it changes+15Messages arrive twice, late, or never
  7. The order is recorded as paid+10Safe to repeat

What it teaches

Safe to repeatintermediate

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.

The rest of Services That Fail Politely