エラーとメッセージの失敗を処理することは、信頼性の高いKafkaコンシューマーにとって重要です。メッセージ処理が失敗したときの対応(リトライ、スキップ、またはデッドレターキューへのルーティング)を決定します。適切なエラーハンドリングはデータ損失を防ぎ、コンシューマーの停止を回避します。
問題:処理の失敗
When a consumer fails to PROCESS a message (bad data, downstream failure, bug):
→ BLOCKING retry forever → the consumer gets STUCK on a "poison" message (can't progress)
→ skipping silently → data LOSS (the message is lost)
→ crashing → consumer restarts, reprocesses, may get stuck again
→ need a deliberate error-handling strategy.
エラーハンドリング戦略
✓ RETRY (with limits) → retry transient failures (with backoff); but LIMIT retries (don't
retry forever on a permanent failure)
✓ DEAD LETTER QUEUE (DLQ) → after retries fail, send the message to a separate DLQ TOPIC →
the consumer moves on (not stuck); the DLQ is inspected/reprocessed later
→ the standard way to handle messages that can't be processed (avoids blocking + loss)
✓ Distinguish TRANSIENT (retry) vs PERMANENT (DLQ/skip) failures
✓ IDEMPOTENT processing → safe retries/reprocessing (at-least-once → duplicates)
