← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

At-Least-Once Delivery

Messaging Intermediate
debt(d9/e7/b7/t7)
d9 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'silent in production until users hit it' (d9). detection_hints.automated is no; duplicate processing only surfaces when users see double charges/emails. No tool flags a non-idempotent consumer.

e7 Effort Remediation debt — work required to fix once spotted

Closest to 'cross-cutting refactor across the codebase' (e7). quick_fix requires making all consumers idempotent, adding message IDs everywhere, building a dedup table, and wrapping process+record in transactions — touches every consumer, not a single-line fix.

b7 Burden Structural debt — long-term weight of choosing wrong

Closest to 'strong gravitational pull' (b7). Per applies_to (queue-workers) and tags (idempotency, reliability), the at-least-once contract shapes how every consumer and message schema is designed; idempotency keys propagate through the system.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap' (t7). The misconception (assuming exactly-once when broker is at-least-once) directly contradicts naive intuition that a delivered message means processed once; common_mistakes confirm the 'obvious' non-idempotent consumer is wrong.

About DEBT scoring →

TL;DR

At-least-once delivery guarantees a message is delivered to at least one consumer, possibly multiple times — consumers must be idempotent to handle duplicates safely.

Explanation

Three delivery guarantees: at-most-once (may lose), at-least-once (may duplicate), exactly-once (ideal, expensive). At-least-once: broker retries unacknowledged messages. Consumer crashes after processing but before ack → redeliver → process twice. Handling duplicates (idempotency): deduplication table (message ID + status), natural idempotency (UPDATE SET status = 'sent' WHERE status = 'pending'), INSERT IGNORE. Kafka: at-least-once by default (manual offset commit after processing). RabbitMQ: at-least-once with manual ack. SQS: at-least-once by design. Message IDs: always include unique ID to detect duplicates.

Common Misconception

At-least-once delivery is a bug — it's a deliberate trade-off. Exactly-once is extremely expensive to implement correctly; at-least-once with idempotent consumers is the practical standard.

Why It Matters

Understanding delivery guarantees is essential for designing correct message consumers — assuming exactly-once when the broker provides at-least-once causes data duplication.

Common Mistakes

  • Non-idempotent consumer with at-least-once broker — double charges, double emails.
  • Not including message ID for deduplication.
  • Using exactly-once where at-least-once + idempotency suffices — unnecessary complexity.

Code Examples

✗ Vulnerable
// Non-idempotent consumer — charges customer twice on redeliver:
function handlePayment($msg) {
    charge($msg['amount']); // No idempotency check
    ack($msg);
}
✓ Fixed
// Idempotent with deduplication:
function handlePayment($msg) {
    $processed = DB::table('processed_payments')
        ->where('message_id', $msg['id'])->exists();
    if ($processed) return ack($msg); // Already done — skip

    DB::transaction(function() use ($msg) {
        charge($msg['amount']);
        DB::table('processed_payments')->insert(['message_id' => $msg['id']]);
    });
    ack($msg);
}

Added 23 Mar 2026
Views 82
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 3 pings M 0 pings T 1 ping W 1 ping T 6 pings F 3 pings S 9 pings S 5 pings M 3 pings T 0 pings W 0 pings T 1 ping F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Scrapy 27 Amazonbot 10 Perplexity 8 Unknown AI 4 Ahrefs 4 ChatGPT 4 Google 3 SEMrush 3 Claude 1 Bing 1 Meta AI 1 Sogou 1 PetalBot 1
crawler 64 crawler_json 3 pre-tracking 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Medium
⚡ Quick Fix
Make all message consumers idempotent. Include message ID in every message. Store processed message IDs in a deduplication table. Use DB transactions for process + record.
📦 Applies To
cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
ack|acknowledge|commit
Auto-detectable: ✗ No
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Medium Context: File Tests: Update


✓ schema.org compliant