preface
In this chapter, we can learn the following knowledge points:
- Why RabbitMQ?
- How is RabbiMQ’s approach to high performance accomplished?
- What is the AMQP Advanced Protocol?
- What are the core concepts of AMQP?
- What is the overall RabbitMQ architecture model?
- How do RabbitMQ messages flow?
1. Meet the RabbitMQ
RabbitMQ is an open source message broker and queue server for sharing data between completely different applications over a common protocol (RabbitMQ can be cross-language). RabbitMQ is written in the Erlang language and is based on the AMQP protocol.
Just from the above sentence, I believe you must have a lot of doubts and questions.
- How ripe is RabbitM?
- How is it used in the industry? Which big factories are using it? Why is that?
- What are the features of RabbitMQ?
- Why is RabbitMQ written in Erlang?
- What is the AMQP protocol? What are the specific specifications in the AMQP protocol?
I’m sure you all have the same doubts as me. So let’s learn about RabbitMQ.
Let’s get to the first one.
2. Why do Internet giants choose RabbitMQ?
How is it used in the industry? Which big factories are using it? Why is that? What are the advantages? As FAR as I know: Didi, Meituan, Qunar, Toutiao…
These big Internet companies use RabbitMQ as a fundamental component of their underlying messaging. Root cause:
- Open source, excellent performance, stability assurance
- Confirm message delivery mode and Return mode are provided.
- Perfect integration with SpringAMQP, stronger scalability, rich API
- Rich cluster mode, expression configuration, HA (high availability) mode, mirror queue model
- Ensure high reliability and availability without data loss
3. How does RabbiMQ achieve high performance?
The reason for this is that it uses the Erlang language, originally an architectural pattern in the switch domain, which makes RabbitQ very good at communicating data between brokers.
It is also up to the author, the author of RabbitMQ development, to make a simple switch in Erlang before RabbitMQ development, and he was surprised to find that Erlang has the same latency as native sockets. I believe that you have come into contact with Socket friends, what kind of performance it has a certain understanding. For example, we are familiar with RPC communication framework. For example: Dubbo, its underlying is the use of Netty, Netty is nothing more than the king of high performance network programming, it is nothing more than a Socket. This is a good reason to choose RabbitMQ. One of the main considerations in choosing RabbitMQ was the latency and response of RabbitMQ messages to RabbtMQ nodes.
4. What is the AMQP Advanced Message Queue protocol?
- AMQP Advanced Message Queuing Protocol
Definition: AMQP is a binary protocol with modern characteristics. Advanced Message queue protocol is an application layer standard that provides unified messaging services. It is an open standard of application layer protocol designed for message-oriented middleware.
It is similar to JMS in Java. Is a higher level specification based on which various types of messaging middleware can be developed.
Model analysis
Pubilsher Application: The producer applies the produced message and throws it to the Server.
Server: specifies the RabbitMQ node
Virtual host: a Virtual host. It is similar to a router. Subsequent introduction
Exchange: a switch to which producers post messages directly. But there are three processes to go through – Server ->Virtual Host ->Exchange
To determine which server to send the message to, you need to establish a connection, set up some addresses, and so on. Second, which Virtual host to post to needs to be defined. At the third level, which Exchange to post to also needs to be defined.
The Consumer simply listens to the Message Queue and consumes it when there is a Message in the Queue. So there is a binding between the Exchange and Message Queue, more on that later.
5. What are the core concepts of AMQP?
AMQP Core Concepts:
- Server: Also known as Broker, receives links from clients and implements AMQP entity services
- Connection: The network Connection between an application and a Broker
- Channel: Network Channel. Almost all operations (data reading and writing) are carried out in a Channel. A Channel is a Channel for reading and writing messages. A client can establish multiple channels, each representing a session task.
- Message: A Message, data sent between the server and the application, consisting of Properties and Body. Properties allows you to modify messages with advanced features such as message priority, latency, and so on. The Body is the message Body content.
- Virtual host: Virtual address used for logical isolation, the top layer of message routing. A Virtual host can contain multiple exchanges and queues. A Virtual host cannot contain exchanges and queues with the same name. A logical concept, similar to Redis logical database. Used to classify specific services.
- Exchange: a switch that receives messages and forwards them to a bound queue based on the routing key
- Binding: Virtual link between exchanges and queues. Binding can contain routing keys
- Routing key: A Routing strand that a virtual machine can use to determine how to route a particular message.
- Queue: Also known as message Queue, message queues that save messages and forward them to consumers.
The above core concepts first have a general cognition, will be introduced in detail later.
6. What is the overall RabbitMQ architecture model?
7. How do RabbitMQ messages flow?
Producer Publisher Application produces the Message to Exchange. Exchange binds to MessageQueue. It can bind multiple MessageQueue. This is mainly because Exchange has a routing function. This route is the routing key, and this route has two key points. First, the Exchange to which your message needs to be sent. Second: You need to send messages with a routing key, and then establish a binding relationship between Exchange and MessageQueue, using the routing key to route the message to a specified queue. Then our consumer side directly listen to the queue on the line, can consume.
At the end of the article
Welcome to focus on individual WeChat public number: Coder programming for the latest original technical articles and free learning materials, is more a large number of high-quality goods, the interview data, mind maps PMP exam information waiting for you to come back, you can anytime, anywhere learning technical knowledge! A new QQ group: 315211365, welcome everyone into the group exchange study together. Thank you very much! Can also be introduced to the side of a friend in need.
Github: github.com/CoderMerlin… Gitee: gitee.com/573059382/c… Welcome to follow and star~
References:
RabbitMQ Message Middleware Technology Introduction
Recommended articles:
Message Middleware — RabbitMQ (part 1) Windws/Linux Setup (Full version)
Message middleware – RabbitMQ (2) A comprehensive comparison of the main message middleware!