Symfony Messenger retry strategy and write idempotency limits
0 reputation · 30 Mar 2023, 13:27 UTC
Symfony Messenger allows for the configuration of a retry_strategy to handle transient failures by defining maximum retries and delays. While this ensures message delivery, the framework does not natively track whether a handler partially succeeded before an exception occurred.
In scenarios where a handler performs a database write but fails before acknowledging the message, the retry mechanism triggers the handler again. This creates a risk of duplicate records if the operation is not naturally idempotent.
Given that the current implementation lacks a built-in deduplication middleware integrated with the retry loop, how can a developer ensure atomic processing without manually implementing a deduplication store for every handler? Is there a recommended way to link the retry state to the message's uniqueness to prevent redundant writes?