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

Exactly-Once Delivery

messaging Advanced

TL;DR

Exactly-once delivery ensures each message is processed exactly once — achievable only with coordination between broker and consumer using transactions or idempotent producers.

Explanation

True exactly-once requires: idempotent producer (Kafka enable.idempotence=true), transactional producer (write + offset commit in one DB transaction), and transactional consumer. Kafka: exactly-once via transactions — producer writes and commits consumer offsets atomically. Cost: lower throughput, higher latency. Alternatives: at-least-once + idempotent consumer (practically equivalent, more portable). Exactly-once semantics (EOS) in Kafka: enable.idempotence=true + transactional.id + isolation.level=read_committed. RabbitMQ: no native exactly-once — use outbox pattern + deduplication. Most real-world systems use at-least-once + idempotency.

Common Misconception

Exactly-once delivery is always achievable — it requires both the broker AND consumer to support transactions. Without transactional consumers, at-least-once + idempotency is the realistic option.

Why It Matters

Understanding exactly-once vs at-least-once helps choose the right architecture — exactly-once is needed for financial transactions; at-least-once + idempotency works for most other cases.

Common Mistakes

  • Enabling Kafka idempotence without transactional consumer — still at-least-once end-to-end.
  • Using exactly-once where at-least-once + idempotency is simpler and sufficient.
  • Not understanding that network failures make true exactly-once impossible across systems.

Code Examples

✗ Vulnerable
// Claimed exactly-once but not transactional end-to-end:
$producer->send($topic, $message); // Idempotent producer
$consumer->process($message); // Not transactional — can fail after produce
✓ Fixed
// Kafka transactional exactly-once:
$producer->initTransactions();
$producer->beginTransaction();
try {
    $producer->send($outputTopic, $result);
    $producer->sendOffsetsToTransaction($offsets, $consumerGroupId);
    $producer->commitTransaction();
} catch (Exception $e) {
    $producer->abortTransaction();
}

Added 23 Mar 2026
Views 35
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 0 pings W 1 ping T 0 pings F 3 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 1 ping W 0 pings T
No pings yet today
Amazonbot 8 Perplexity 8 Google 5 ChatGPT 3 Unknown AI 3 SEMrush 2 Ahrefs 1
crawler 28 crawler_json 1 pre-tracking 1
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: High
⚡ Quick Fix
Use Kafka transactions for true exactly-once. For most cases: at-least-once + idempotent consumer is equivalent and simpler. Use outbox pattern for DB-to-broker exactly-once.
📦 Applies To
cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
initTransactions|beginTransaction
Auto-detectable: ✗ No
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: High Context: File Tests: Update

✓ schema.org compliant