intermediate
Consumer
Design consumers for idempotency, acknowledgement timing, concurrency, backpressure, poison-message handling, and observable lag.
Consumers pull or receive messages, deserialize, execute handlers, and acknowledge or commit offsets only after safe processing. Design for idempotency, controlled concurrency, backpressure, poison-message quarantine, and observable consumer lag.
Trade-off: higher concurrency speeds processing but may break per-key ordering unless partitioned correctly.
On interviews: when to ack before versus after processing; handle a message that always throws.
Common pitfalls: unbounded parallel handlers on ordered stream; commit offset before DB transaction commits; no lag alerts.
Checklist:
- Idempotent handlers with inbox or natural keys.
- Match concurrency to ordering guarantees.
- Commit offsets after durable side effects.
- Alert on growing lag and DLQ volume.