Choosing a message delivery guarantee is a trade-off between data loss, duplicate work, latency, storage, and implementation complexity. This practical guide compares at-most-once, at-least-once, and exactly-once behavior, then gives you a repeatable worksheet for selecting the right guarantee for each event type.
Overview
Message delivery guarantees describe what a messaging system promises when a producer sends an event and a consumer processes it. The three commonly discussed models are at-most-once, at-least-once, and exactly-once. They are useful design labels, but they should not be treated as universal properties that a broker can provide without application-level decisions.
For example, a broker may persist a message reliably, while a consumer still performs the same business operation twice after a timeout. The important question is therefore not only, “Will the broker deliver this message?” It is also, “What happens if the consumer receives it again, fails midway, or cannot confirm completion?”
| Guarantee | Loss risk | Duplicate risk | Typical latency and cost | Suitable workloads |
|---|---|---|---|---|
| At-most-once | Possible if a failure occurs before processing is confirmed | Designed to avoid redelivery | Usually the lowest operational overhead | Disposable telemetry, presence signals, and noncritical notifications |
| At-least-once | Designed to avoid loss through acknowledgements and retries | Duplicates are possible and must be handled | Moderate overhead from persistence, retries, and deduplication | Orders, payments workflows, webhooks, and reliable asynchronous processing |
| Exactly-once | Requires carefully defined transaction boundaries | Can limit duplicate effects within a supported scope | Often higher coordination, storage, and implementation complexity | Workflows where repeated effects are difficult to reconcile and the platform supports the required semantics |
The safest default for many business events is at-least-once delivery combined with idempotent message processing. The consumer records a stable event ID, uses an idempotency key, or applies a conditional database operation so that retrying the same event does not create a second business effect. This approach makes failure recovery explicit without assuming that a distributed system can eliminate every duplicate at every boundary.
At-most-once may be appropriate when a missing event is less harmful than delaying the system or repeating an action. Exactly-once can be valuable, but define its scope precisely: it may apply to a broker transaction, a stream-processing topology, or a particular output sink, rather than to every external side effect such as an email provider, payment gateway, or webhook destination.
How to estimate
Use a decision worksheet for each event class instead of selecting one guarantee for the entire platform. Start with the consequence of loss and duplication, then estimate the operational cost of preventing each failure mode.
- Classify the event. Separate business commands, state changes, notifications, analytics events, and ephemeral signals. A request to charge an account should not inherit the same policy as a typing indicator.
- Rate the consequence of loss. Use a simple scale from 0 to 3: 0 means the event can be safely ignored; 1 means it reduces freshness; 2 means it creates a support or reconciliation task; 3 means it can cause financial, contractual, safety, or material operational harm.
- Rate the consequence of duplication. Use the same scale. Consider whether a duplicate is harmless, visible to a user, expensive, or capable of creating an incorrect state.
- Measure the recovery path. Ask whether the event can be replayed, rebuilt from a source of truth, or reconciled later. If recovery is difficult or impossible, increase the required reliability.
- Identify the effect boundary. Document where the message is read, where the database changes, and where external calls occur. A guarantee is only as strong as the least controlled boundary in the workflow.
- Select the simplest sufficient model. Choose at-most-once when loss is acceptable, at-least-once when loss is not acceptable and duplicates can be made safe, and exactly-once only when its scope and supporting mechanisms are understood.
A useful planning estimate is to treat reliability as two separate quantities: delivery exposure and effect exposure. Delivery exposure is the chance that an event is unavailable, expired, or permanently lost. Effect exposure is the cost of applying it more than once. Retries reduce the first quantity but can increase the second unless consumers use idempotency, deduplication, or transactional coordination.
For systems with retries, estimate duplicate volume as a planning range rather than a precise forecast. List the causes that can trigger redelivery: consumer crashes, acknowledgement timeouts, connection loss, broker failover, deployment interruption, and downstream timeouts. Then test the consumer with repeated delivery, delayed acknowledgements, and partial completion. A guarantee that is not verified under these conditions is only an assumption.
Inputs and assumptions
Record these inputs before selecting a delivery guarantee:
- Business criticality: What is the impact of losing, delaying, or duplicating the event?
- Replayability: Can the event be recovered from a retained log, database, source system, or dead-letter queue?
- Event identity: Does every message carry a stable event ID, aggregate ID, or idempotency key that survives retries?
- Ordering requirement: Must events be processed in order for one customer, account, device, or aggregate? Ordering and delivery guarantees are related but separate decisions.
- Retry window: How long should the system retry before moving an event to a dead-letter queue or an operational review queue?
- Retention and storage: How much broker retention, retry storage, deduplication state, and audit history are needed?
- External side effects: Can an email, payment request, inventory update, or webhook be safely repeated? If not, does the destination support an idempotency key?
- Observability: Can operators see acknowledgement failures, retry counts, consumer lag, processing duration, duplicate detection, and dead-letter volume?
Do not equate a successful acknowledgement with a completed business transaction. A consumer may acknowledge too early and lose work, or acknowledge too late and cause a duplicate after the work has already completed. Define the acknowledgement point deliberately. For database-backed consumers, an atomic database update and an inbox or processed-event record can make duplicate handling auditable. For producer-side reliability, a transactional outbox can help coordinate a database change with eventual message publication; see the transactional outbox pattern guide.
Security and governance belong in the same worksheet. Retried messages may contain sensitive data, and dead-letter queues often outlive the normal processing path. Apply access controls, encryption, retention limits, and audit logging to retry and failure stores. The messaging encryption and key rotation guide provides a related checklist.
Worked examples
Example 1: Realtime presence updates
A collaboration application publishes “user is online” and “user is typing” events. The latest state supersedes older state, and a missing update is corrected by the next heartbeat or presence refresh. Loss has a low consequence, while retries could create stale or noisy signals. At-most-once delivery is a reasonable starting point. Keep message expiry short and make the client tolerate silence by refreshing state periodically.
Example 2: Webhook-to-queue order events
An external service sends an order confirmation through a webhook. A network timeout may occur after the receiving service has stored the request, causing the sender to retry. At-most-once handling risks losing an order. Use at-least-once ingestion, verify the webhook, assign or preserve a stable event ID, and make storage conditional on that ID. Process the event through a retry policy and dead-letter workflow. The webhook-to-queue integration guide covers this pattern in more detail.
Here, “exactly once” is not a safe blanket promise. The receiving database can record one order event, but a downstream email or third-party API may still require its own idempotency control.
Example 3: Stream aggregation
A stream-processing job calculates account totals from events. Reprocessing an event can inflate a total unless the processor tracks offsets, event IDs, or a transactional state update. If the platform and sink support a well-defined exactly-once processing scope, it may be justified. Otherwise, at-least-once delivery with replayable events and deterministic, idempotent aggregation may offer a clearer operational model.
In each example, the selected guarantee follows the failure consequences rather than the broker brand. Use the same discipline when comparing message queue solutions, pub/sub systems, or event streaming platforms.
When to recalculate
Revisit the decision whenever the event’s business meaning, processing path, or operating conditions change. Recalculate after adding a new consumer, moving from an internal database to an external API, changing retention or retry settings, introducing batching, or altering partitioning and ordering rules. A change in message volume can also expose new failure modes: longer queues, more consumer lag, larger retry backlogs, and higher deduplication storage requirements.
Review the worksheet at least during an architecture review or reliability exercise, and sooner after a production incident involving loss, duplicates, out-of-order processing, or an overloaded dead-letter queue. Platform version changes can also affect transaction, acknowledgement, retry, or ordering behavior, so confirm the current implementation details before relying on a guarantee.
To act on this guide, create a short register with one row per event type and these columns: consequence of loss, consequence of duplication, replay source, idempotency key, ordering scope, retry window, dead-letter owner, and selected guarantee. Test the highest-risk rows with forced crashes and repeated delivery. Then link alerts to the operational owner and document the recovery procedure. This turns message delivery guarantees from a product label into a maintained reliability control.