What is Idempotency Messages?

5

I have a question on the subject here , and a < a href="http://blog.jonathanoliver.com/idempotency-patterns/"> article on the subject even at Wikipedia, but I have not yet understood the subject, so the questions are,

  • What is Idempotency Messages ?
  • How and where should it be used?
  • Simple example of use?
asked by anonymous 03.08.2017 / 14:05

1 answer

5

An idempotent operation can be understood as something that establishes a value or state instead of modifying it.

A simple example might be the bank balance. Imagine the extract below:

Data             Valor        Operação
01/01/2017      100,00        Abertura de conta + Depósito inicial
02/01/2017      -14,99        Netflix
03/01/2017      -20,00        Refeição
04/01/2017      -30,00        Táxi
01/02/2017        5,01        Saldo Atual
02/02/2017      +14,99        Extorno - Netflix

If you want to know the balance of this account on 06/01/2007 you can not only observe the last amount processed, because it is a modifier (-30 reais on 1/4) . You need to consider all modifications until you find the first value defined by an idempotent operation - in this case, the account opening with the value of 100 reais.

The message on 01/02 can also be considered an idempotent operation: Many systems use this mechanism to facilitate state assessments. In the example above you do not need to recalculate all values until the first operation to determine the current balance.

    
03.08.2017 / 15:17