RabbitMQ Publisher Confirms: Reliable Message Publishing
Fast recall
Quick revision
Core answer
Knowledge of the full end-to-end delivery guarantee chain, not just the consumer side.
Confusing publisher confirms with consumer acks — confirms are a broker-to-producer signal, acks are a consumer-to-broker signal. Also forgetting to set publisher-returns=true to catch messages routed to no queue.
Explain the difference between simple, correlated, and none confirm types in Spring AMQP, and describe how to use CorrelationData to correlate confirms back to specific messages for retry logic.
Interview-ready guide
Interview answer
Publisher confirms close the gap between a producer calling convertAndSend and the broker actually persisting the message to disk. Without them, the method returns after writing to the TCP buffer — if the broker crashes before completing the disk write, the message is lost and the producer never finds out.
How confirms work:
- In confirm mode, the broker sends a
basic.ackback to the producer after the message is on disk; if it cannot handle the message, it sendsbasic.nack - This is the opposite direction from consumer acks — confirms are broker-to-producer, consumer acks are consumer-to-broker; they cover opposite sides of the delivery pipeline
Confirms vs returns — two different failure modes:
- A confirm tells you the broker received and persisted the message; but if the exchange has no matching binding, the message is silently discarded — the confirm still comes back positive
- Publisher returns catch routing failures; enable them with
publisher-returns: trueandmandatory: trueon the template — withoutmandatory, unroutable messages are dropped without triggering the callback
Implementation in Spring AMQP:
- Use
CORRELATEDconfirm type and attach aCorrelationDatawith a unique ID to each publish;CorrelationData.getFuture()resolves when the broker responds, allowing per-message retry logic - For production-grade reliability, back pending messages with a database outbox rather than in-memory maps — in-memory pending maps lose data on crash
I recommend always enabling publisher confirms in production for any business-critical message, and combining them with publisher returns to cover both persistence failures and routing failures.
RabbitMQ Publisher Confirms: Reliable Message Publishing
Direct Answer
Publisher confirms are an AMQP extension where the broker sends an ack or nack back to the producer after a message is persisted to disk. They bridge the gap between the producer calling send and the broker guaranteeing receipt, preventing message loss at the publish side. In Spring AMQP, enable them via spring.RabbitMQ.publisher-confirm-type=correlated and use ConfirmCallback on RabbitTemplate.
Common Mistakes & Pitfalls
Confusing publisher confirms with consumer acks — confirms are a broker-to-producer signal, acks are a consumer-to-broker signal. Also forgetting to set publisher-returns=true to catch messages routed to no queue.
Check your understanding
Answer these without looking back at the article.
- What is the difference between publisher confirms and transactions in RabbitMQ?
- How do you handle a broker nack in production without losing the original message payload?
- Do publisher confirms work with quorum queues? Are there any differences in semantics?
Related interview prep categories
1Want a guided curriculum order?
These modules are also sequenced in our flagship backend interview track — open it when you prefer an ordered path instead of browsing by topic.