Messagingacknowledgmentacknacktcp ack

Acknowledgement

Definition

An acknowledgement (ack) tells the sender that data arrived or a message was handled. Missing acks are what trigger retransmission in TCP and redelivery in message brokers.

In practice

In TCP, the receiver acknowledges the next byte it expects; the sender keeps unacknowledged data and retransmits it after a timeout or after duplicate ACKs signal a gap. In a message broker, the consumer acks after processing, and only then is the message deleted or the offset committed. A negative ack (nack) asks for redelivery straight away.

When you ack decides your delivery guarantee. Ack before processing and a crash loses the message (at most once); ack after processing and a crash causes a redelivery (at least once), so handlers must be idempotent. Brokers that wait too long for an ack redeliver healthy but slow work, which is the visibility timeout problem.

Example

A worker receives message m-881, writes the order to the database, then sends the ack; if it crashes between the two, the broker redelivers m-881 and the inbox table skips the duplicate.