Let's have a personal explanation.
Message Queuing, as the name implies, is a queue first.
The operation of the queue has 入队 and出队
That is, you have a program that produces content and then the queue (producer) Another program reads content, content out of the team (consumer)
I think you should be lacking a usage scenario.
When you don't need to get the results immediately, but the concurrency is not infinite, it's pretty much the time you need to use Message Queuing.
For example, you write a log, because there may be a client has more than one operation to write, and there are many clients, obviously concurrency can not be infinite, so you need to write the log request into the message queue, in turn, the consumer side of the queue generated by the log into the database.
2. Message Queuing resolves a burst of requests to the backend can withstand the queue request, such as your server can handle 100 orders a second, but the second kill activity 1 seconds come in 1000 orders, lasts 10 seconds, in the case of the back-end capacity can not increase, You can use Message Queuing to put a total of 10,000 requests in the queue, the background consumer according to the original ability processing, 100 seconds after processing all requests (instead of directly down the loss of order data)
3. So first do not implement the message queue yourself (before you have used various message queues, but also seen one or two source code), and then there is no appropriate demand for Message Queuing
In layman's words, it is a container, you throw the message in, do not need to deal with it immediately. Then there is a program to read the messages out of your container and handle them. Message Queuing, which can be activemq,kafka, or a task table for a database.
Personally think message queue, there are two main functions:
- Reduced coupling
- Messages can be temporarily present in the message queue, waiting for the message receiver to control the processing speed of processing messages based on its own load handling capacity, reducing the pressure on large concurrent accesses.
4. The data structure of the queue, the most original data structure. is used to store models for producer consumers.
Java Message Queuing