Course contentsShow
← Computer Science
Lesson 2711 of 2,87260. Distributed Data and CommunicationFree lesson

Message Acknowledgment and Redelivery

How consumers confirm message processing, handling failures, and automatic redelivery mechanisms in queues.

Message Acknowledgment and Redelivery

What you'll learn: How message queues ensure reliable processing by requiring consumers to confirm receipt and automatically redelivering messages when things go wrong.

The Problem

Imagine sending a package through the mail—you want confirmation it arrived safely. Similarly, when a message queue delivers a message to a consumer, it needs proof the consumer successfully processed it. Without this confirmation, messages could be lost forever if a consumer crashes mid-processing.

How Acknowledgments Work

When a consumer receives a message from a queue, it must explicitly acknowledge (ACK) successful processing back to the broker. Until the broker receives this acknowledgment, the message remains "in flight" and hasn't been considered delivered.

Think of it like a restaurant's order ticket system: the kitchen doesn't throw away the ticket until the waiter confirms the meal was delivered to the customer. If something goes wrong (waiter drops the plate), the ticket is still there to remake the order.

Redelivery on Failure

If a consumer crashes or sends a negative acknowledgment (NACK) before completing processing, the broker automatically redelivers the message—either to the same consumer (when it recovers) or to a different healthy consumer.

Common redelivery triggers:

  • Consumer crashes without ACK
  • Explicit NACK from consumer
  • Acknowledgment timeout expires
  • Network failure during processing

Acknowledgment Timing

Consumers typically acknowledge messages after successful processing, not upon receipt. This ensures the "at-least-once" delivery guarantee we learned earlier: even if processing fails, the message survives for retry.

Key Takeaway: Message acknowledgments are the handshake between consumers and brokers that enable reliable delivery—consumers confirm successful processing, and brokers automatically redeliver unacknowledged messages, preventing data loss in distributed systems.