Common scene description message queue

In Baidu Encyclopedia, the message queue is so explained: "Message Queue" is to preserve container message during transmission of the message.

This explains the "message" refers to a unit of data transfer between two computers. Message can be very simple, for example, contain only text strings; may be more complex, and may contain embedded objects. Message is sent to the queue.

"Message queue" message is stored in a container in the message transmission process. Message queue manager acts as an intermediary when the relayed message from its source to its target. The main purpose of the queue is guaranteed to provide routing and delivery of messages; if the recipient is unavailable to send a message, the message queue message will remain until it can successfully pass.

 

Usually at work, we are also common message queue, such as kafka, rabbitmq etc., most companies are basically in use, of course, there are ways to simulate the use redis message queue, of course, it is not recommended.

 

The following scene, and according to the information available I normally use common scene in general that the next message queue.

The main features of the message queue is an asynchronous process, the main purpose is to reduce the response time and decouple the request.

The main usage scenario is to take effect without the need for time-consuming operation immediately return a result, we put this operation as a message into the message queue. The processor may go to acquiring and processing the message at any time. Here we only guarantee the same format of the message, the sender and receiver of the message processing side know this news, so the two sides do not need to communicate with each other, that is one thing that can be done.

 

Of course, if we use a message queue, then there are many points to note. For example, the sender of the message recipient does not need to immediately return the results, otherwise it can only wait for the result of the processing; for example, the system will be short-lived inconsistency, the sender recipient unpredictable what time processing this message. Of course, the actual production or the need to allow such a place, the message queue is now unusual hot.

 

Below cite an example online (feel, very vivid image):

Assume that the user registered in the software, the server receives a registration request from the user, it will do these actions:

Check the user name and other information, if the problem can not add a user record in the database if it is sent by registered mail will give you a registration successful message, the phone will send a text message registered personal information of the user analysis for the future he recommended a number of like-minded people, or those who recommended him to the system informs the user that contains the operating instructions sent to and so on ......

 

But for users, the actual registration function requires only the first step, as long as the service ends his account information into the database he will be able to log on to do what he wanted to do things. As for other things, to the server can be placed in other operations corresponding to the message queue and immediately returns the user a result, these operations are performed by the asynchronous message queue.

Guess you like

Origin www.cnblogs.com/cuihongyu3503319/p/10978599.html