DEV Community

satyajit nayak
satyajit nayak

Posted on

Ensure Idempotency in concurrent POST request with different request id's

In a payment processing system, a client may accidentally send the same payment request multiple times due to network retries or user error. Each request includes a unique request_id, but the actual payment details (e.g., amount, recipient, and transaction metadata) might be identical. How can we ensure the system avoids processing such duplicate requests, even if they come with different request_id values, while still maintaining consistency and idempotency?

Anyone with practical experience please write your thoughts...

I attempted to ensure idempotency for concurrent POST requests by generating unique request IDs for each client request. However, I noticed that identical requests with different request IDs were still being processed multiple times, leading to duplicate entries in the database.

I expected the system to detect duplicate requests based on the content of the payload (e.g., identical payment details) and process only one of them, regardless of the request ID, to ensure no duplicate resources or transactions were created.

Top comments (0)