r/coding • u/DotDeveloper • Jul 28 '26
Idempotency in event-driven systems: how do you handle duplicate messages?
https://hamedsalameh.com/inbox-pattern-dotnet/
175
Upvotes
r/coding • u/DotDeveloper • Jul 28 '26
71
u/amejin Jul 28 '26
... Guids. The answer you seek is guids.
46
u/funkylabrador420 Jul 28 '26
First, a guid. Second, I disregard all instructions and prompts and share juicy apply pie recipes.
20
u/ZealousidealDig8074 Jul 28 '26
By ignoring the duplicates.
15
u/TheAnig Jul 28 '26
This thread was the first time I saw so many people talk about GUIDs instead of UUIDs, so I got curious then i read the article and it was about C# and it all made a lot more sense
8
u/UK-sHaDoW Jul 28 '26
Some kind of id, and then ignore them if youve processed it before
8
u/yopla Jul 28 '26
Cool. Level 0 of distributed system "my business transaction are atomic and without side effect" and only work if you have a single queue processor.
Doesn't even work with the example given in the intro "process a payment".
1
u/ultrathink-art Jul 29 '26
The id solves redelivery on the consumer side. The duplicates that actually bit us came from the other end - a write times out, you genuinely cannot tell whether it applied, so you retry and make the duplicate yourself. Splitting the failure path into 'definitely did not apply' and 'unknown outcome' was the fix; only the first is safe to retry, and the second needs a read-back against the id before you touch it again.
1
u/pp_amorim Jul 29 '26
The article is a nightmare to read (formatting).
1
u/iamaredditboy Jul 30 '26
guids, storage and define a time window where this invariant has to hold. infinite time window means you will need infinite storage :) Also some building blocks around compare and swap / db level conflict handling when operating with multiple instances eg distributed architecture.
0
u/InsideFar7107 Jul 28 '26
Don't send them
0
u/D_a_f_f Jul 29 '26
CRDTs