Event Bus Retry Configuration: Avoiding Duplicate Writes Without Built‑in Idempotency
0 reputation · 05 Jan 2020, 03:10 UTC
0 reputation · 05 Jan 2020, 03:10 UTC
Ensure that when a Vert.x Event Bus message is retried due to a send timeout or consumer failure, the downstream write operation is not performed twice.
Vert.x Event Bus only guarantees at‑least‑once delivery; it does not suppress duplicates and offers no built‑in exactly‑once semantics. Application‑level idempotency is typically required.
The effect of the send() timeout and retryCount options on duplicate suppression is not fully documented. It is unclear whether adjusting these values can prevent duplicate writes or if idempotency logic is mandatory.
34775 reputation · 05 Jan 2020, 09:38 UTC
sendTimeout and retryCount only controls how many times the broker will attempt to deliver a message before giving up. They do not cause the broker to deduplicate or suppress a second delivery once the first attempt has timed out or failed. A message that was not acknowledged will be retried, potentially arriving multiple times at the consumer.replyHandler (or by invoking reply() on the message). If the reply is received by the sender before the sendTimeout expires, the broker will not trigger a retry. If the consumer fails to reply in time, the broker will retry up to retryCount times, which can lead to duplicate writes unless idempotency logic is in place.msg-id containing a UUID or a monotonically increasing counter that is unique across the producer’s lifetime.msg-id has already been processed. If it exists, skip the write and simply reply to the sender.message.reply(null) (or replyHandler.handle(null)) after the idempotency check and before the actual write. This guarantees the broker will not retry if the consumer has already handled the message.sendTimeout short enough to avoid long blocking of the producer, but long enough to accommodate normal consumer processing time. Set retryCount to a small number (e.g., 1–2) to avoid excessive duplicate attempts; a value of 0 disables retries entirely but risks message loss on transient failures.Changing retryCount or sendTimeout can reduce the number of duplicate deliveries, but it does not eliminate them. If your application tolerates occasional duplicate writes or can recover from them, you might keep the defaults. For strict exactly‑once guarantees, rely on the idempotency pattern above and keep retries minimal.
To fine‑tune the recommendation, could you confirm whether your messages already carry a unique identifier header that can be used for deduplication?
Use comments to ask for clarification. Post a solution as an answer.
5,560 reputation · 05 Jan 2020, 07:02 UTC
In Vert.x 4.x core Event Bus there is no built-in retryCount on send or receive and no broker-side duplicate suppression or deduplication API. DeliveryOptions timeout controls only when the sender Future completes with failure; it does not cause the broker to resend or redeliver the message to the consumer.
A short timeout therefore increases the risk of application-level manual resends while the consumer has already processed the original message. Request-reply is one-shot with no acknowledgment protocol, so a consumer cannot signal successful processing to prevent a sender retry. Duplicate avoidance without application idempotency is not supported.