Idempotency pattern
When we are aiming for message-driven and asynchronous communication, it can bring some challenges along. For example, if a duplicate message is added to the system, will it corrupt the state? Say we have a bank-account update service, and we send a message to add $1,000 to the account. What if we have a duplicate message? How will the system make sure it does not add the money twice just because a duplicate message is received? Also, how will this system differentiate between a duplicate message and a new message?
There are various techniques that can be used to handle to this problem. The most common is to add a message number or ID to each message, so the system can make sure that each message with a unique ID gets ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access