The idempotency strategy is widely applied in scenarios, for example, charging a double payment. In the microservices scenario we are talking about a request for a POST/PUT/PATCH or even an event that arrives through the Stream.
Some Stream services eventually send duplicate messages to ensure high delivery speed, and this forces applications to control Idempotency.
DevPrime offers a very flexible approach to configuring the service that can be configured to start automatically, by a parameter sent by the consumer and/or restricted to specific processes according to the strategy of each microservice.
The Idempotency feature can be configured to work automatically using the “action” parameter as “auto” and “flow” as “backend” without the need to pass a foreign key.
To visualize in practice the scenario and the importance of idempotency follow the sequence of images where we demonstrate in the Log generated by the DevPrime Observability strategy.
Posting to the Order API
When you look at the log you will already have the idempotência information as active for this request
Making a second post in the Order API identical to the previous one
The API result already reports the refusal of the duplicate request
When analyzing the log in the section of the idempotência you will find the “Reject”
Two-step Idempotency setup
Enable Idempotency in the “DevPrime_App” key
Add a second persistence Redis in the “State” key
Activating manual Idempotency
Adding idempotency in the Order API
You just checked out a powerful feature present in DevPrime Stack. Use Devprime to accelerate the journey of application modernization and digital platform development.