3 major usage scenarios of message queues

The message queue can be regarded as a knowledge point that must be asked in the current interview. Moreover, if you say no, it's as if someone else has caught your shortcomings.

3 major usage scenarios of message queues

There are a bunch of people everywhere now, and the market price is too different from the previous year. Today, for the sake of discomfort and embarrassment, I can talk to the interviewer even better. I will tell you about the three major usage scenarios of message queues.

Of course, the message queue is definitely not limited to these three scenarios. My generalization is quite general. To seize the main scene is to seize the opportunity of the interview.

1. Services that support asynchronous processing.

This is a big scene used by message queues. For example, in e-commerce projects, we can support and use message queues for order placement, delivery, inventory deduction, SMS notification, report statistics, etc.

In these scenarios, with the message queue, the user experience is also very high. For example, if we do not use the message queue, we need to go out of the library after the payment is successful, we need to directly initiate the outgoing request to the gateway after the payment is successful, or notify the outgoing library through a timed task. However, after the message queue, asynchronous processing can be supported.

For another example, some of our orders are to reduce inventory, and some are to pay for inventory. With the message queue, the order service and inventory service can be better processed asynchronously. Moreover, with the change of the status of an order, many subscriptions can be formed for orders of different status.

Some people may also ask that only asynchronous processing does not show the advantages of message queues. Then let's take a look at the second largest usage scenario.

2. Flow limitation, flow or velocity control.

Like queuing in reality, message queues can also control the flow rate. Similarly, when producers and consumers cannot consume quickly, they can use message queues for accumulation.

For another example, in a spike scenario, 1,000 people may have 1,000 designs. However, it is also a good way to use message queues to limit concurrency.

3. Reduce the coupling degree of the code

To say a thousand words and ten thousand, I can also achieve business functions without using message queues. However, can decoupling be achieved while realizing functions? This is also a key in architecture design. The higher the degree of coupling, the harder it is to expand.

Moreover, after decoupling, you can form subscriptions for different topics at any time. Especially for fast-developing systems, changes are common. When we can achieve decoupling, the degree of change between the upstream system and the downstream system will not be so high. The art of structural balance is fully utilized.

The above 3 points do not fully summarize the usage scenarios of message queues, but I think these are particularly important 3 points. If you also have ideas and usage scenarios, please leave a message and make progress together!

Guess you like

Origin blog.51cto.com/15127565/2664945