Message middleware-the advantages and disadvantages of MQ and the comparison of each message middleware

1. What is MQ

       Message queue (MQ) is an application-to-application communication method. Applications communicate by writing and retrieving application-specific data (messages) in and out of the queue, without the need for a dedicated connection to link them.

       The above is Baidu Baike's definition of MQ. Simply put, MQ is used for data transfer between systems. For example, if there is a message transfer between A system and B system, our common way may be that one system provides an interface, and another system calls the interface to transfer data to meet business needs. However, a better way is to use message queues. Assuming that system A needs to deliver a message to system B, system A can write a message to the message queue, and system B can monitor the message queue. When there is a message, system B can take the message from the message queue for consumption .

2. Advantages of MQ

       You may ask: It is obvious that the communication between systems can be carried out by calling the interface, why use MQ? Using MQ certainly has his benefits, the main benefits are three points: decoupling, asynchronous and peak clipping.

3. Disadvantages of MQ

1. The system availability is reduced. For example, if MQ is introduced into the system, what should I do if MQ fails? Once the MQ hangs up, the communication between the systems is completely disconnected, causing the system to be unavailable. This happens in reality. Generally speaking, the more external dependencies are introduced, the more fragile the system will be, and each dependency will cause the entire system to collapse.
2. Increased system complexity. Originally, the system can be called directly through the interface. If MQ is introduced, various situations of MQ need to be considered, such as: repeated consumption of messages, message loss, guaranteed consumption order, etc..., so that the system More and more complicated.
3. Data consistency issues. For example, the system A has already returned to the customer the operation success. At this time, the operation BC is successful, but the operation D fails, resulting in inconsistent data.

       Therefore, in the normal function development of the software, there is no need to deliberately find the usage scenarios of the message queue, but when there is a performance bottleneck, to check whether there is a time-consuming operation that can be processed asynchronously in the business logic, and if it exists, it can be introduced Message queue to solve. Otherwise, the blind use of message queues may increase the cost of maintenance and development but can not get a considerable performance improvement, then the gain is not worth the loss.

 

 

During development, which message middleware should be selected, here are some tips:

1. ActiveMQ is not recommended anymore, because the community is very active and no one will maintain it anymore. Once a problem occurs during use, it is more difficult to find a solution;

2. RabbitMQ is now used more, the throughput has reached ten thousand, and the delay is low, one of the best advantages is that it provides a back-end management system, very useful for small and medium-sized companies; at the same time From a point of view, the community is also relatively active. The disadvantage is that the development language uses the erlang language. For Java developers, the erlang language is more difficult to understand and cannot be studied in depth and can only be used simply.

3. Alibaba of RocketMQ is open source, and now the community is relatively active, and it is developed in Java language and supports distributed clusters. But there is a risk of being deprecated. Once Ali is not maintained at any time, it may be discarded. If it is a big company with the ability, it is okay to study the source code and maintain it by yourself. If it is a small company, then it will be pitted.

4. Kafka is mainly used in the field of big data. Its main advantage is its high throughput and it is also distributed 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/bj_chengrong/article/details/102689117