One 、 Preface
Now most of them use MQ To make the system heterogeneous , To decouple the system , The module of the system is equivalent to the sender and receiver ,MQ It plays the role of post office . As a transit role , You need to make sure that the message 100% The delivery .
Today we're going to study how to make sure that the news 100% Delivery of . Put together a copy of Java Interview book full version PDF
Two 、 Let's talk about RabbitMQ Characteristics of
RabbitMQ The assurance is ： As long as you deliver the message to Broker in , Then I'll make sure that the message reaches the consumers .
Of course, there are preconditions , such as ：
You need to respond manually ,
Minimum Broker Don't hang up , And the message is persisted .
combination RabbitMQ To make an analysis , For the delivery end , We just need to make sure that the message is sent to Broker Then you can , So how to ensure reliability , In the following steps ：
The message was successfully sent out
Guarantee Broker Successfully received the news
The producer received Broker The confirmation response
Message compensation mechanism , All three steps are kneeling , Make a compensation retransmission mechanism
The last barrier , If there are too many retries in step 4 , So there's something wrong with the system , We need human intervention
Just do the five steps above , Basically we can guarantee , Message delivery 100% Send it out . in addition , Official account Java Technology stack , Reply in the background ： interview , I can get the RabbitMQ A series of interview questions and answers , Very complete .
3、 ... and 、 The guarantee of the reliability of the producer's delivery
3.1 Let's start with the diagram
3.2 As for the above illustration , Let's step by step analyze
step1： Data in the database , This step is necessary
step2： Put the message in the library , And the initialization state is 0 （ In sending ）
step3： Deliver the message to Broker in
step4：Broker Send successful response
step5： The producer gets a successful response , Modify message status to 1:（ Send successfully ） All of the above are normal processes , Let's talk about the abnormal solution mechanism ：
step6： Periodically check whether the status of the message is 1
step7： If step6 The status of the message for is still 0 , Then go to resend , repeat .........