Part 07 · Revision sheet

Messaging, Event-Driven Architecture and Data Processing

Key Terms

  • Asynchronous request–reply — an async transport carrying a correlation ID, with an answer still delivered on a reply channel (→ 105)
  • Message queue — a broker-managed durable buffer holding messages until a consumer acknowledges them (→ 106)
  • Competing consumers — multiple consumers reading one queue; each message is handled by exactly one of them (→ 106, 107)
  • Consumer group — a set of consumers dividing a topic's partitions so each partition is read by exactly one member at a time (→ 108)
  • Consumer lag — the gap between a partition's latest offset and the group's committed offset (→ 108)
  • Publish/subscribe — delivers each published message to every subscriber, not just one (→ 109)
  • Dead-letter queue — a holding queue for messages that fail every retry attempt (→ 117)
  • At-least-once — never loses a message, may deliver it more than once; the practical default (→ 115)
  • Idempotent consumer — processing the same message twice produces the same end state as processing it once (→ 116)
  • Transactional outbox — writes the business change and the event to publish in the same database transaction (→ 118)
  • Change data capture — tails a database's write-ahead log and turns row changes into an event stream (→ 119)
  • Event sourcing — the append-only event sequence is the source of truth; current state is derived by replay (→ 120)

Decision Rules

  • Stay synchronous until a measured reason justifies decoupling; use async request–reply when the caller still needs an eventual answer (→ 105)
  • Use publish/subscribe when every interested party needs its own copy of an event; use competing consumers when exactly one consumer should act on it (→ 107, 108, 109)
  • Pick a partition key matching the entity whose events must stay ordered; don't pay for global ordering unless the business genuinely needs one timeline (→ 114)
  • Treat at-least-once plus idempotency as the default for anything with business consequence; never claim exactly-once as a free broker property once an external system is involved (→ 115, 116)
  • Use the dead-letter queue for messages that will eventually fail regardless of retries, not as the primary path for predictable validation errors (→ 117)
  • Use the transactional outbox when you control the writing service's code; use CDC when events must be derived from a database you don't fully control (→ 118, 119)
  • Reserve event sourcing for domains that genuinely need a perfect audit trail and point-in-time queries; most CRUD systems are better served by a current-state table plus an audit log (→ 120)
  • Use workflow orchestration for multi-step processes needing one visible owner of state, timeouts, and compensations; a chain of background jobs is enough when no compensation logic is needed (→ 121, 122)
  • Use batch processing for bounded data where some latency is acceptable; move to stream processing only when results must arrive within seconds (→ 123, 124)
  • Choose Kafka for high-throughput replay and multiple independent consumers of the same history; choose RabbitMQ-style routing for task queues and rich routing with lower operational weight (→ 111, 112)

Numbers & Formulas

  • Consumer lag(partition) = latest offset(partition) − committed offset(partition) (→ 108)
  • Retained log storage ≈ throughput × average message size × retention window (→ 111)
  • Burst backlog = (arrival rate − drain rate) × burst duration; drain time = backlog ÷ drain rate (→ 110)

Traps

  • A consumer written for at-most-once assumptions silently double-counts the first time at-least-once redelivers it (→ 115)
  • Checking for a duplicate and applying its effect as two separate, non-transactional steps reopens the exact race idempotency was meant to close (→ 116)
  • An unmonitored dead-letter queue fills silently while the business impact goes unnoticed until a customer complains (→ 117)
  • Publishing right after a database commit with no outbox leaves a permanent window where a crash loses one side of the write (→ 118)
  • Treating processing time as event time looks correct in testing and silently misattributes events to the wrong window under real network jitter (→ 124)

Self-Quiz

  1. Can you label a two-service interaction as sync, async fire-and-forget, or async request–reply, and defend the choice? (no → revisit 105)
  2. Can you compute the minimum consumer count to hold consumer lag flat, and explain what a rebalance does to in-flight work? (no → revisit 108)
  3. Can you classify a described delivery behavior into at-most-once, at-least-once, or effectively-once, and say what breaks under the wrong assumption? (no → revisit 115)
  4. Can you explain why publishing right after commit, with no outbox, has a permanent failure window? (no → revisit 118)
  5. Can you choose a window type for a given stream aggregation and state your watermark trade-off in one sentence? (no → revisit 124)

Search the guide