Introduction
A message often goes through the following stages,
so to ensure the reliable delivery of the message, you only need to ensure the reliable delivery of these three stages.
Production stage
Reliable delivery at this stage mainly relies on ConfirmListener (publisher confirmation) and ReturnListener (failure notification).
As mentioned earlier, the flow of a message in RabbitMQ is
producer -> rabbitmq broker cluster -> exchange -> queue -> consumer
ConfirmListener can get whether the message is sent from the producer to the broker
ReturnListener can get the message that cannot be routed from the exchange to the queue
I use Spring Boot Starter's api to demonstrate the effect
application.yaml
spring:
rabbitmq:
host