0
0
RabbitMQdevops~10 mins

Publisher confirms in RabbitMQ - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Publisher confirms
Start Publisher
Enable Publisher Confirms
Send Message to Exchange
Wait for Broker Ack/Nack
Confirm Success
Continue or Retry
The publisher sends a message and waits for the broker to confirm if it was received successfully (ack) or not (nack).
Execution Sample
RabbitMQ
channel.confirmSelect()
channel.basicPublish(exchange, routingKey, props, message)
channel.waitForConfirms()
Enable confirms, publish a message, then wait for confirmation from RabbitMQ.
Process Table
StepActionMessage Sent?Broker ResponsePublisher State
1Enable publisher confirmsNoN/AWaiting to send
2Publish message to exchangeYesWaiting for ack/nackWaiting for confirmation
3Broker sends ackYesAck receivedMessage confirmed
4Publish next message or finishDependsN/AReady for next message
💡 Publisher confirms received ack, message delivery confirmed.
Status Tracker
VariableStartAfter Step 2After Step 3Final
message_sentfalsetruetruetrue
broker_responsenonewaitingackack
publisher_stateidlewaiting_confirmconfirmedconfirmed
Key Moments - 3 Insights
Why does the publisher wait after sending the message?
The publisher waits to receive an ack or nack from the broker to know if the message was successfully received, as shown in step 2 and 3 of the execution table.
What happens if the broker sends a nack?
If a nack is received, the publisher knows the message was not confirmed and can retry or handle failure. This is the alternative path after step 3 in the concept flow.
Can the publisher send multiple messages before waiting for confirms?
Yes, but each message will be confirmed in order. The example shows waiting after one message for simplicity, but confirms can be handled asynchronously.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the publisher state after step 2?
AIdle
BMessage confirmed
CWaiting for confirmation
DFinished
💡 Hint
Check the 'Publisher State' column at step 2 in the execution table.
At which step does the broker send an ack?
AStep 3
BStep 1
CStep 2
DStep 4
💡 Hint
Look at the 'Broker Response' column in the execution table.
If the broker sends a nack instead of an ack, what should the publisher do?
AIgnore and continue
BRetry or handle failure
CShutdown immediately
DSend a duplicate message without waiting
💡 Hint
Refer to the concept flow where nack leads to 'Handle Failure'.
Concept Snapshot
Publisher confirms in RabbitMQ:
- Enable confirms with channel.confirmSelect()
- Publish message with basicPublish()
- Wait for ack/nack with waitForConfirms()
- Ack means message received, nack means failure
- Use confirms to ensure reliable delivery
Full Transcript
Publisher confirms in RabbitMQ allow the publisher to know if a message was successfully received by the broker. The publisher first enables confirms, then sends a message. After sending, it waits for the broker to send an acknowledgement (ack) or negative acknowledgement (nack). If ack is received, the publisher knows the message was delivered successfully. If nack is received, the publisher can retry or handle the failure. This process helps ensure reliable message delivery in RabbitMQ.