People talk about idempotency like it is a solved problem:
Put an Idempotency-Key on the request. Store the response. Replay it on retry.
And yes, that is doable. For the happy path, it is even fairly small.
The client sends:
POST /payments Idempotency-Key : abc-123 Content-Type : application/json
{ "accountId" : "acc_1" , "amount" : "10.00" , "currency" : "EUR" , "merchantReference" : "invoice-7781" }
The server checks whether it has seen abc-123 . If not, it creates the payment. If yes, it returns the previous response.
That version survives the demo.
The part I contest is that this is the hard part. It is not. The hard part starts with the second request, because the second request is not always a clean replay of the first one.
Maybe it is a completed replay. Fine. Return the stored result.
... continue reading