In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to understand RabbitMQ core concepts and AMQP protocol," interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "how to understand RabbitMQ core concepts and AMQP protocol"!
directory
preface
1. First meeting RabbitMQ
2. Why do Internet manufacturers choose RabbitMQ?
3. How does RabbiMQ's high performance approach work?
4. What is AMQP Advanced Message Queue Protocol?
5. What is the core concept of AMQP?
6. What does RabbitMQ's overall architecture model look like?
7. How do RabbitMQ messages flow?
preface
In this chapter, we learn the following:
Why do Internet manufacturers choose RabbitMQ?
How does RabbiMQ's high performance approach work?
What is AMQP Advanced Protocol?
What is the core concept of AMQP?
What does RabbitMQ's overall architecture model look like?
How do RabbitMQ messages flow?
1. First meeting RabbitMQ
RabbitMQ is an open source message broker and queue server used to share data between disparate applications via common protocols (RabbitMQ enables cross-language, cross-platform mechanisms), RabbitMQ is written in Erlang, and RabbitMQ is based on the AMQP protocol.
Just through the above sentence, I believe that everyone must have a lot of doubts and questions.
How mature is RabbitM?
How about industry adoption? Which big factories are in use? Why not?
What are the characteristics of RabbitMQ?
Why RabbitMQ should be written in Erlang?
What is AMQP protocol? What are the specific specifications in the AMQP protocol?
I am sure that everyone will have the same doubts as me. Let's learn RabbitMQ together.
Let's get to the first question.
2. Why do Internet manufacturers choose RabbitMQ?
How about industry adoption? Which big factories are in use? Why not? What are the advantages?
As far as I know: Didi, Meituan, Qunar, Headline…
These big Internet companies use RabbitMQ as a fundamental component of their underlying messaging. Root cause:
Open source, excellent performance, stability guarantee
Provide reliability Message delivery mode (confirm), return mode (return)
Perfect integration with SpringAMQP, enhanced extensibility, rich API
Cluster pattern rich, expression configuration, HA (high availability) pattern, mirror queue model
High reliability and availability without data loss
3. How does RabbiMQ's high performance approach work?
The reason is that it uses Erlang language, Erlang language originally in the switch domain architecture pattern, so that RabbitQ in the Broker data exchange performance is very good.
Another point also depends on the author, RabbitMQ development author before the development of RabbitMQ, first in Erlang language to make a simple switch, and then he was surprised to find: Erlang advantages: Erlang has as good as the native Socket latency effect.
I believe that everyone who has contacted Socket friends has a certain understanding of its performance. Like the RPC communication framework we are familiar with. For example: dubbo, its bottom layer is the use of Netty, Netty is nothing more than the king of high performance in network programming, it is nothing more than a Socket.
Based on this feature, we have a good reason to choose RabbitMQ. In fact, when we choose RabbitMQ, one of the main considerations is the delay and response of RabbitMQ when messages enter RabbtMQ nodes.
4. What is AMQP Advanced Message Queue Protocol?
AMQP stands for Advanced Message Queuing Protocol.
AMQP definition: is a binary protocol with modern characteristics. is an application layer standard Advanced Message Queue Protocol that provides unified messaging services. It is an open standard for application layer protocols and is designed for message-oriented middleware.
It is similar to JMS in Java. It is a relatively high-level specification, based on which various message middleware can be developed.
model analysis
Publisher application: The producer applies the messages produced and throws them to the server.
Server: refers to RabbitMQ nodes
Virtual host: A virtual host, a route at the upper level, similar to a router. as illustrated below
Exchange: A switch where producers deliver messages directly to Exchange. But there are three steps to go through-> server->Virtual host->Exchange
First determine which server to send the message to, then you need to establish a connection, set up some addresses, and so on.
The second layer, to which Virtual Host delivery needs to be defined.
The third layer, which Exchange to deliver to also needs to be defined.
Looking at the application side of the Consumer application, the consumer side only needs to listen to the Message Queue, and when there is a message in the queue, it will be taken out for consumption. Therefore, there is a binding relationship between Exchange and Message Queue, which will be described in detail later.
5. What is the core concept of AMQP?
AMQP core concepts:
server: also known as Broker, receives client links and implements AMQP entity services
Connection: Link, network connection between application and Broker
Channel: Network channel, almost all operations (reading and writing data) are carried out in Channel, Channel is the channel for reading and writing messages. Clients can establish multiple Channels, each representing a session task.
Message: Data transferred between server and application, composed of Properties and Body. Properties can modify the message, such as the message priority, delay and other advanced characteristics;Body is the message body content.
Virtual host: Virtual address, used for logical isolation, the highest level of message routing. A Virtual Host can have several Exchange and Queue, and the same Virtual Host cannot have Exchange and Queue with the same name. A logical concept similar to Redis logical database. It is used to classify specific services.
Exchange: Switch that receives messages and forwards them to bound queues based on routing keys
Binding: Virtual connection between Exchange and Queue. Binding can contain routing key.
Routing key: A routing rule that a virtual machine can use to determine how to route a particular message.
Queue: Also known as message Queue, a message queue that holds messages and forwards them to consumers.
The above core concepts have a general understanding first, and will be introduced in detail later.
6. What does RabbitMQ's overall architecture model look like?
Producers post messages to Exchange, and Exchange posts messages to Queue.
So our producers only need to focus on delivering messages to the specified Exchange, and our consumers only need to listen to the specified Queue. It's such a simple mechanism.
We can also see from the diagram that producers do not need to pay attention to which queue they are delivered to, and consumers do not need to pay attention to which Exchange they come from. These two pieces are not coupled. There should be a binding relationship between Exchange and Queue.
7. How do RabbitMQ messages flow?
Producer publisher application produces Message delivery to Exchange. Exchange binds MessageQueue. Multiple MessageQueue can be bound. Why only one of the three queues receives message? This is mainly because Exchange has a routing function. This route is the routing key. This route has two very critical points.
The first one: Which Exchange does your message need to be sent to?
The second one: When you send a message, you need to bring the routing key, and then establish a binding relationship between Exchange and MessageQueue, and route the message to a specified queue through the routing key. Then our consumer directly listens to the queue, and we can consume it.
At this point, I believe everyone has a deeper understanding of "how to understand RabbitMQ core concepts and AMQP protocol," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.