Saturday 8 November 2008

Why is idempotence so important?

Every enterprise system has some operations that need to occur only once.

Typically transactions are used to guarantee only once processing. Although transactions work well inside applications they don't work so well when connecting systems together.

Distributed transactions do guarantee only once processing given infinite time, however during this time resources are often locked and this may cause the applications to become unusable.

The use of transactions to guarantee only once processing between connected systems is therefore not practical, but building an unreliable system is senseless so we need an alternative.

Without transactions the best we can do is ensure a message will be delivered at least once. If we need to ensure only once processing, we need to make sure the target system won't duplicate the work if it receives duplicate messages.

In other words, we need the target system to be idempotent.

No comments: