Idempotent consumers can ignore duplicate api requests (requests with same Idempotency-key) or duplicate messages (typically generated by retries)

Problem

Client sends api requests to server but might not get a response becuase of connection timeout . The client has no way of knowing if the request is successful or failed . To make sure that the request is processed, the client has to retry the request. If the server has allready the processed the request then this would lead to the same logical request executing twice.

In case of message brokers a server may process a message and crash before acknowledging the message. The broker could crash and lose the acknowledgment. Message broker would typically retry untill message is processed successfully (so that atleast once delivery of message is guranteed)

Solution

An idempotent consumer can perform de-duplication and gurantee that message or api is successfully executed only once.

Few techniques are possible