What is the usage scenario for Message Queuing?often hear such as REBBITMQ,ACTIVEMQ, ask your predecessors what is the usage scenario for Message Queuing and when will it be used?
- Verify user name information, and add a user record to the database if no problem occurs
- If it is registered with the mailbox will send you a successful registration of the mail, mobile phone registration will send a text message
- Analyze the user's personal information so that he can be recommended to some like-minded people in the future or recommend him to those people
- Send to the User a system notification containing an operation guide
- Wait a minute......
In addition to these, the more commonly used is to play the peak of the need to use:
For example, your server can handle 100 orders a second, but the second kill activity 1 seconds to come in 1000 orders, lasting 10 seconds, in the case of the back-end capacity can not increase, you can use Message Queuing to press a total of 10,000 requests in the queue, backstage consumer according to the original ability to handle, After 100 seconds, all requests are processed (rather than direct downtime loss of order data).
Technology solves the problem, and Message Queuing addresses the ability to convert bursts of requests into queue requests that can be sustained by the backend.
It's very light and quiet.
Links: https://www.zhihu.com/question/34243607/answer/127666030
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source. Scienjus
Links: https://www.zhihu.com/question/34243607/answer/58314162
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.
Personally, the main feature of Message Queuing is asynchronous processing, the main purpose is to reduce the request response time and decoupling. So the main usage scenario is to put a time-consuming operation that does not require an immediate (synchronous) return result to be placed in the message queue as a message. At the same time, because of the use of Message Queuing, as long as the message format is guaranteed, the sender and receiver of the message do not need to contact each other, and do not need to be affected by each other, namely decoupling and.
Use the scene, for example:
Assuming the user registers in your software, the server receives the user's registration request, and it does the following:
- Verify user name information, and add a user record to the database if no problem occurs
- If it is registered with the mailbox will send you a successful registration of the mail, mobile phone registration will send a text message
- Analyze the user's personal information so that he can be recommended to some like-minded people in the future or recommend him to those people
- Send to the User a system notification containing an operation guide
- Wait a minute......
However, for the user, the registration function actually only needs the first step, as long as the server to store his account information in the database he can log in to do what he wants to do. As for the other things, do you have to do it all in this one request? Is it worth the user wasting time waiting for you to deal with things that don't matter to him? So when the first step is done, the server can put the other operations into the corresponding message queue and return the user results immediately, which is done asynchronously by Message Queuing.
Or there is a situation, at the same time there are a large number of users register your software, and then high concurrency when the registration request began to have some problems, such as the mail interface can not withstand, or analyze the information when the large number of calculations to make the CPU full, this will occur although the user data records are quickly added to the database, However, when the card in the mail or analysis of information, the response time of the request increased significantly, or even a timeout, which is a little cost-effective. In this case, it is common to put these operations into the message queue (producer consumer model), Message Queuing slowly processing, and can quickly complete the registration request, does not affect the user to use other features.
So in the normal function of software development, do not need to deliberately look for the message Queue usage scenario, but when the performance bottleneck, to see if the business logic there is a time-consuming operation can be asynchronous processing, if there is a message queue can be introduced to solve. Otherwise, blindly using Message Queuing may increase the cost of maintenance and development without a noticeable performance gain, which is not worth the candle.
How to use Java Message Queuing