Idempotent Filter Pattern

Learn the Idempotent Filter design pattern and its usage.

Intent

This pattern filters out duplicate messages and ensures unique messages are passed through.The Idempotent Filter pattern is also known as the Idempotent Receiver EIP.

Context and problem

Idempotency is the property that allows certain operations to process the same request multiple times without causing any side effects. Some operations are idempotent by nature, and it is safe to execute them multiple times without any side effects. Read-only operations (retrieving a value or executing a complex query) do not change the system state and are idempotent. There are other operations that do change the system state, but they are also idempotent. For example, delete or update/set operations that do not depend on the original state of the system but set a new value with each request are idempotent; deleting a bank account or updating its status with the same value multiple times will have the same effect as doing it once.

Other operations are not safe to be invoked multiple times. These are operations that create new values with each invocation and ones that depend on the system’s current state. For example, an operation that creates a new bank account or another operation that adds an amount to an existing account cannot be safely invoked multiple times without side effects. The Idempotent Filter pattern can turn a nonidempotent operation into an idempotent one.

Forces and solution

Let’s imagine we have invoked a remote ...