Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the meaning of message middleware in RabbitMQ

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the meaning of message middleware in RabbitMQ. It is very detailed and has a certain reference value. Friends who are interested must read it!

What is message middleware?

Message middleware is a subsystem of the distributed system, which focuses on the sending and receiving of data, and integrates the other subsystems of the distributed system by using efficient and reliable message passing mechanism.

Usage scenario of message Middleware

1. Asynchronously handle the asynchronization of non-core processes to improve system response performance

It turns out that after registering, the user may have to write to the database in turn, and send e-mail and text messages before he can prompt the user to register successfully.

Now, as long as you write the database, after writing the message queue, you will directly prompt the user to register successfully, and sending emails and text messages are processed asynchronously, which improves the response speed.

two。 Application decoupling

The system is not strongly coupled, and the message receiver can be added at will without the need to modify the code of the message sender. The success of the message sender does not depend on the message receiver.

Rpc implementation

Message queue implementation

If there is something wrong with the inventory system, the user will not be able to place an order normally, which is unreasonable. It can be decoupled through message queuing.

When a new system, such as an advertising system, is also interested in the user's order, you only need to get the message from the message queue, and the order system does not need to be changed at all.

3. Flow peaking

When there is a gap in the processing capacity of the upstream and downstream systems, message queues can be used for buffering.

Insert a picture description here

When there is a second kill service, when there are a large number of requests pouring in, the system is likely to be paralyzed. At this time, you can buffer it with a message queue.

4. Log processing

Message queuing is used in log processing, such as Kafka can be used to solve the problem of a large number of log transfers

5. Message communication

Message queues generally have built-in efficient communication mechanisms, so they can also be used for simple message communication, such as implementing peer-to-peer message queues or chat rooms.

Chronicle of message Middleware

To see the first light

1. As a matter of fact, message middleware was born very early. In the era when Internet application was still barren, an Indian buddy Vivek Ranadive in the United States imagined a general software bus, which adopted the mode of publish and subscribe and was connected to other corresponding programs like the bus on the motherboard. He founded a company, Teknekron, and implemented the world's first messaging middleware, The Information Bus (TIB).

fight the enemy separately

2.TIB was welcomed by enterprises, and the business development of Teknekron attracted the attention of IBM, the most bullish IT company at that time, so they also began to develop their own message queuing software, so there was later wesphere mq, and Microsoft joined the regiment one after another. Because of commercial barriers, commercial MQ vendors want to solve the problem of application interoperability, rather than to create standards to achieve interoperability between different MQ products, or to allow applications to change the MQ platform

To rob the world.

3. In order to break down this barrier and to enable messages to communicate among message queuing platforms, JMS (Java Message Service) arises at the historic moment. JMS attempts to hide the actual interfaces provided by individual MQ product suppliers by providing public Java API, thus overcoming barriers and solving the problem of interoperability. Technically, Java applications only need to program for JMS API, choose the appropriate MQ driver, and JMS will take care of the rest. ActiveMQ is an implementation of JMS. However, trying to glue together many different interfaces using separate standardized interfaces will eventually expose problems and make the application more vulnerable. Therefore, there is an urgent need for a new message communication standardization scheme.

Unify the rivers and lakes

4. In June 2006, the public standard of AMQP was jointly formulated by Cisco, Redhat, iMatix, etc., from which AMQP stepped onto the stage of history. It is an open standard of application layer protocol to solve the requirements and topology structure of many message middleware. It is designed for message-oriented middleware. The client and message middleware based on this protocol can transmit messages, and are not limited by product, development language and other conditions.

If we stay together for a long time, we must divide.

5.LinkedIn feels that the AMQP specification is not suitable for it when implementing message queues, so Kafka does not support the AMQP protocol. RocketMQ draws on the idea of Kakfa in its implementation, so it does not support the AMQP protocol, and you will find that there are concepts similar to Topic and Consumer Group in both Kafka and RocketMQ, but these concepts do not exist in the AMQP protocol.

How to choose message Middleware

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

The ActiveMQ community is relatively mature, but compared to the current, ActiveMQ performance is relatively poor, and version iteration is very slow, so it is not recommended.

Although RabbitMQ is slightly inferior to Kafka and RocketMQ in terms of throughput, because it is based on erlang development, it has strong concurrency, excellent performance, and low latency, reaching microsecond levels. But also because RabbitMQ is based on erlang development, few domestic companies have the strength to do erlang source-level research and customization. If the concurrency requirement of the business scenario is not too high (100,000 or million), then RabbitMQ must be your first choice among the four message queues. If it is real-time computing, log collection and other scenarios in big data's field, using Kafka is the industry standard, absolutely no problem. The community is very active and will never be yellow, not to mention it is almost a factual norm in this field all over the world.

RocketMQ Ali produced, Java is an open source project, the source code we can read directly, and then we can customize our own company's MQ, and RocketMQ has Alibaba's actual business scenarios of the actual combat test. The activity of the RocketMQ community is relatively mediocre, but it is OK, and the documentation is relatively simple.

The characteristics of Kafka are obvious, that is, it provides only a few core functions, but provides ultra-high throughput, ms-level latency, high availability and reliability, and the distribution can be extended at will. At the same time, Kafka is best to support a small number of topic to ensure its ultra-high throughput. The only disadvantage of Kafka is the possibility of repeated consumption of messages, which will have a very slight impact on data accuracy, which can be ignored in big data's field and log collection. Kafka is naturally suitable for big data's real-time computing and log collection.

Message model

What if you were to design a message queue? How will you make it happen?

Maybe you will immediately think of using the queue, putting it and taking it at the same time. This is actually a common message model of message queue, queue model.

So a simple message queue can be implemented using List in Redis. Of course, after the Redis5.0 version, a data structure Streams is specially designed for the scenario of message queuing.

What are the disadvantages of the queuing model?

If you send a class of messages to different consumers, each consumer has to receive all the messages, which is very inconvenient at this time. Because you want to send the same message to different queues, one more consumer will have to send one more queue. In this way, producers must know how many consumers there are, which is not conducive to decoupling.

So how to solve this problem?

Think about the structure diagram of RabbitMQ.

RabbitMQ does not send messages directly to the queue, but to Exchange, where Exchange is associated with Queue, and messages are sent by Exchange to the corresponding queue according to the rules. In this way, producers and consumers are decoupled.

Is there any other way to solve this multi-consumer problem?

Yes, it's the publish and subscribe model.

Both RocketMQ and Kafka are implemented based on the publish / subscribe model. The message model of RocketMQ is shown below.

Producers are publishers, consumers are subscribers, and messages are topics.

To improve the parallelism of consumption, a class of messages are distributed to multiple queues, called Queue in RocketMQ and Partition in Kafka, are similar concepts.

Detailed explanation of AMQP protocol

As mentioned earlier, there are two protocols for message middleware, JMS and AMQP. JMS can be compared to JDBC, and you can build a set of interfaces for different vendors to implement this interface, but the design of this protocol is not elegant enough, so you won't introduce this protocol, unless you use ActiveMQ, it's really useless to learn. Let's talk about the AMQP agreement in detail. After all, there are still many companies that use RabbitMQ now. If you want to learn the RabbitMQ,AMQP protocol well, you must be clear.

AMQP protocol model

The picture above is the flow process of a message in the AMQP protocol, which is very clear and will not be introduced in detail.

AMQP core concepts introduce some common concepts of the AMQP protocol.

Conceptual interpretation

Concept explanation Server, also known as Broker, accepts client connections and implements AMQP entity services Connection a network connection, such as an independent two-way data flow channel in a TCP/IP socket connection Channel multiplexing connection. Provides the physical transport medium Message messages for the session, the data transferred between the server and the application, which consists of Properties and Body. Properties can modify the message, such as message priority, delay and other advanced features. Body is the message body content Virtual Host virtual address, which is used for logical isolation and top-level message routing. There can be several Exchange and Queue in a Virtual Host, and there can be no Exchange or QueueBinding message queue with the same name in the same Virtual Host. The switch can use this message header to decide how to route a message Message Queue message queue, which can be used to save the message until it is sent to consumers. Thank you for reading all the contents of the article "what does message middleware in RabbitMQ mean?" Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report