当前位置:网站首页>How to ensure reliable delivery of messages?

How to ensure reliable delivery of messages?

2022-06-11 02:57:00 ambition_ forever

1、 Production stage :

      Ensure through request confirmation mechanism , That is, the producer sends messages Broker in the future ,Broker After successfully receiving the message , Send back ACK Confirm that the producer , The generator receives Broker Sent ACK After the confirmation , It is considered that the consumption has been successfully sent . If you don't receive it for a long time ACK, The producer will try again , Or throw an exception to the user .

2、 Storage phase :

         The storage phase is as long as Broker In normal operation , There will be no lost messages . But if Broker There's a problem , For example, the process is dead or the server is down , Or you may lose messages .

        If it's a single instance Broker Transformation of , You can set the synchronous brush disk , That is, when you return ACK Before Broker First write the message to disk , Prevent messages from being lost because the server is unavailable , You can get data from the disk the next time you restart .

        If more than one Broker The clustering pattern composed of instances , At least two sets shall be set Broker Received producer message , To send ACK confirm .

3、 Consumption stage :

         The consumption phase uses a similar approach to the production phase to ensure that messages are not lost ,Consumer from Broker After pulling the news , After successfully executing the business logic , Will give Broker Send consumption confirmation ACK. If Broker No confirmation of consumption has been received ACK Transformation of , The next time Consumer The same message will be returned when the message is pulled , Ensure that messages are not lost during network transmission , It won't be because of Consumer Loss due to error in executing business logic .

 

原网站

版权声明
本文为[ambition_ forever]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110232211174.html