確認応答(acks)はRabbitMQにメッセージが正常に処理されたことを知らせ、キューから削除できるようにします。これらは確実な配信に不可欠です — コンシューマーが失敗してもメッセージが失われないようにします。
確認応答の仕組み
When a consumer receives and processes a message, it ACKNOWLEDGES it:
→ ACK → "I've processed this message" → RabbitMQ removes it from the queue
→ if a consumer DIES before acking (crash, disconnect) → RabbitMQ REQUEUES the message
→ redelivered to another consumer (NOT lost)
→ acks ensure messages are processed reliably (not lost if a consumer fails)
手動確認応答と自動確認応答
MANUAL ack → the consumer explicitly acks AFTER processing → reliable (message redelivered
if processing fails) — the safe choice for important messages
AUTOMATIC ack → the message is considered acked as soon as it's DELIVERED (before processing)
→ faster but UNSAFE → if the consumer crashes during processing, the message is LOST
→ use MANUAL acks for reliability (ack only after successful processing)
