In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
The editor of this article introduces in detail "how to implement reliable message service in micro-service". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to implement reliable message service in micro-service" can help you solve your doubts. Let's follow the editor's ideas to learn new knowledge.
A common solution
There are many ways to solve distributed things, and there are a lot of summaries on online blogs. Generally speaking, there are two kinds of solutions.
1 rigid distributed transaction with strong consistency of two-phase commit
2 flexible distributed transaction best effort commit, tcc, reliable message service
First of all, solve the premise guarantee of distributed transaction: the interface must be idempotent to prevent the impact of message repetition on business.
Second, reliable message system design (this feels good and relatively simple, just share it)
As shown above
Start execution such as: try {if (prepare ()) {/ / pre-send phase doService (); / execute business logic updateMsgStatus (); / / update message for confirmation status}}
1 pre-sent message, try phase, if the pre-sent message fails, the business has not been executed, so the system AMagi B is consistent and does not need to be processed.
This is easy to understand.
2 the pre-sending message is successful, and the business logic begins to be executed. Perform a successful update pre-sent message to confirm delivery. If the execution of the business logic fails at this time, the pre-sent message will not follow the new status, and the message confirmation system will start the work and check the status of the message on business system 1. If it is found that the business execution has failed, update the pre-sent status to the failed state.
3 if the business execution is successful and the message is updated to confirm that it has been sent, then ok is perfect. If the message update fails, it is still up to the message confirmation system to check to update the deleted status or confirm the sending status of the message.
4 messengers start to consume
1 > for example, if the consumption fails and inconsistency occurs at this time, the message recovery system detects the status of the message and resends the message.
2 > if the execution of the business fails, the message will not be confirmed, or the message recovery system will detect the status of the message and resend the message
3 > if the ask fails, or if the above logic resend the appeal, of course, there is a limit on the number of times, and cannot be sent all the time. If you exceed the maximum number of times, you will enter the dead letter queue and wait for human intervention.
4 > if ask succeeds, messages will be consumed successfully, perfect, and reliable message service will be solved.
3. Strive to submit
This is relatively simple, the failed message will be submitted repeatedly, and some scenarios with weak real-time performance can ensure that the message is pushed successfully.
For example, the completion of the transaction and the push of third-party messages. At this point, you can use effort to submit
After reading this, the article "how to implement reliable messaging Services in Micro Services" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.