In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the function of message queue in Java". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the role of message queue in Java".
1. The coupling between these interfaces is serious, and each new downstream function needs to modify the relevant interfaces. For example, if system A wants to send data to systems B and C, the data sent to each system may be different, so system An assembles the data to be sent to each system, and then sends it one by one. After the contemporary code is online, a new requirement has been added: send the data to D. At this point, we need to modify system A to make him aware of the existence of D, and at the same time process the data to D. In this process, you will see that every time you connect to a downstream system, you have to modify the code of system A, and the efficiency of developing joint debugging is very low. Its overall structure is shown below:
2. In the face of large traffic concurrency, it is easy to be washed out. The handling capacity of each interface module is limited, and this upper limit capacity is easy to be washed away when large flow (flood) comes.
3. There are performance problems. The RPC interface is basically synchronous invocation, and the overall service performance follows the "bucket theory", that is, the slowest interface in the link. For example, A calls B/C/D as 50ms, but B calls B1 at this time, which costs 2000ms, which directly affects the performance of the entire service.
According to the above questions, the goals to be achieved can be clearly defined when designing the system:
To decouple the system, code changes can be minimized when new modules are connected.
Set up a traffic buffer pool to allow the back-end system to consume according to its own throughput capacity without being washed out.
Strength-dependent carding asynchronizes the operation of non-critical calling links and improves the throughput capacity of the overall system. For example, A, B, C and D in the figure above allow users to initiate payment and then return several key processes for successful payment prompts. B1 is the module that notifies the merchant of delivery after payment, so in fact, users have a large tolerance for B1 completion time (for example, a few seconds later), so it can be asynchronized.
In the current line of sight of the system, MQ message queue is widely used, which can be a perfect tool to solve these problems. The following figure is a simple architecture diagram using MQ. You can see that MQ stores the flood at the front end, while the downstream system ABC only deals with MQ and parses it through a pre-defined message format.
The system architecture and interaction mode after the introduction of MQ is very different from the original chain call architecture. Although it can solve the problems mentioned above, it is necessary to fully understand its principle and characteristics to avoid its side effects. Here, we take a look at the implementation of MQ based on how message queuing ensures "reliable delivery of messages".
1. How does Client deliver messages to MQ reliably?
1.Client sends messages to MQ
After 2.MQ persists the message, sends the Ack message to Client. Here, the Ack message may not be sent to Client due to network problems. Then Client will retransmit the message after waiting for the timeout.
After receiving the Ack message, 3.Client believes that the message has been delivered successfully.
2. How does MQ deliver messages to Client reliably?
1.MQ push the message to Client (or Client to pull the message)
2.Client gets the message and finishes the business logic
3.Client sends an Ack message to MQ, informing MQ to delete the message. Here, Ack may fail due to network problems, then Client will repeat the message, which leads to the problem of consumption idempotence.
4.MQ deletes consumed messages
Thank you for reading, the above is the content of "what is the role of message queue in Java". After the study of this article, I believe you have a deeper understanding of what the role of message queue in Java is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.