What an ack does
When a broker hands a message to a consumer, it needs to know whether the work succeeded before it can forget the message. That signal is an acknowledgement, or ack. A negative signal, the nack, says processing failed and asks the broker to redeliver.
Auto ack vs manual ack
- With auto ack, the broker marks the message done the moment it is delivered. If the consumer crashes mid work, the message is gone. This is fast but unsafe.
- With manual ack, the consumer acks only after the work fully completes. If it crashes first, the broker redelivers the message to another consumer.
Why timing matters
The rule of thumb is to ack after the side effect, not before. Ack early and you risk losing work on a crash. Ack late and a slow consumer may hold messages, but nothing is lost. Many brokers also enforce an ack deadline: if no ack arrives in time, the message is requeued automatically.
Key idea
Acknowledge a message only after its work is durably complete so a crash leads to redelivery rather than silent loss.