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 principle and function of RabbitMQ

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

Share

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

This article introduces the relevant knowledge of "RabbitMQ's principle and function". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

1. Introduction to mainstream message middleware 1) ActiveMQ: message middleware produced by Apache, fully supporting JMS specification, rich API, multiple cluster construction modes, widely used in small and medium-sized enterprises, and poor performance in the face of super-large concurrency. 2) Kafka: Open source distributed publish-subscribe messaging system, based on pull mode to handle message consumption, pursuing high throughput, initially intended for log collection and transmission, does not support transactions, has no strict requirements for message duplication, loss, and errors, is suitable for data collection services that generate large amounts of data, and emphasizes high performance.3) RocketMQ: Ali open source, pure Java development, with high throughput, high availability, suitable for large-scale distributed systems, its idea originated from Kafka, which optimizes the reliability of message transmission and transaction.4) RabbitMQ: The open source message queue system developed using Erlang language is implemented based on AMQP protocol. AMQP protocol is more applied in enterprise systems. The scenarios with high requirements for data consistency, stability and reliability are also secondary to performance and throughput requirements. 2. The reasons for RabbitMQ high performance 1) Erlang language is initially based on the architecture model of the switch field. 2) The advantages of Erlang: Erlang has the same latency as native Socket. 3. What is AMQP Advanced Message Queue Protocol? It is a binary protocol with modern characteristics. It is an application layer standard advanced message queue protocol that provides unified messaging services. It is an open standard for application layer protocols. It is a norm.

4. AMQP core concepts 1) Server: also known as Broker, accepts connections from clients and implements AMQP entity services 2) Connection: network connection between applications and Broker 3) Channel: network channel, almost all operations are carried out in Channel,Channel is a channel for message reading and writing, clients can establish multiple Channels, each Channel represents a session task. 4) Message: Message, composed of Properties and Body,Properties can modify the message body, such as priority, delay and other advanced characteristics,Body is the message content 5) Virtual host: Virtual address, used for logical isolation, the highest level of message routing. A Virtual Host can have several Exchange and Queue, the same Virtual Host can not have the same name Exchange and Queue6) Exchange: switch, receive messages, according to the routing key forward messages to the bound queue. Producer throws messages onto Exchange,Exchange performs a route to bound Message Queue 7) binding: virtual connection between Exchange and Queue,binding can contain routing key8) Routing key: a routing rule that virtual machines can use to determine how to route a particular message 9) Queue: also known as Message Queue, message queue, stores messages and forwards them to consumers 5. RabbitMQ overall architecture

Producer sends MQ message with two key parameters:1) Specify which Exchange to send to 2) Specify Routing Key, establish a binding relationship through Exchange and Message Queue, route to specified Message Queue6) Exchange Switch Exchange: Receive message and forward message to bound queue according to routing key Switch properties 1) Name: Switch name 2) Type: Switch type, have direct, topic, fanout, headers3) Durability: Whether persistence is required 4) Auto Delete: Automatically delete the Exchange when the last queue bound to Exchange is deleted 5) Arguments: Extension parameters, used to extend AMQP protocol Custom use Switch type: 1) Direct Exchange: All messages sent to Direct Exchange are forwarded to Queue specified in Route Key Note:Direct mode can use RabbitMQ comes with Exchange:default Exchange, so there is no need to bind Exchange for any operation, message delivery, Route Keys must match exactly to be received by the queue, otherwise they are dropped 2) Topic Exchange: All messages sent to Topic Exchange are forwarded to all Queue that care about the Topic specified by Route Key. Exchange performs fuzzy matching between Route Key and a Topic, and queues need to bind a Topic. See the figure below Topic Exchange3) Fanout Exchange: Do not process routing keys, just simply bind the queue to the switch, do not set the route key. Messages sent to the switch will be forwarded to all queues bound to the switch, which forwards messages fastest.

7. Binding, queue, message, virtual host detailed explanation 1) Binding Connection between Exchange and Exchange, Queue 2) Message Queue Durability, whether it is durable Auto Delete, if yes is selected, this Queue will be deleted automatically after the last monitor is removed 3) Message Data passed between server and application Essentially a piece of data consisting of Properties and PayLoad(Body) Common attributes: delivery mode(whether messages are persisted on Broker), headers(custom attributes)4) Virtual Host logical concept, virtual address, for logical isolation, top-level message routing A Virtual Host can have several Exchange and Queue The same Virtual Host can not have the same name Exchange or Queue"RabbitMQ principle and role is what" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

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