RabbitMQ study notes: a preliminary exploration of the principle

1. Brief introduction:

RabbitMQ is an open source implementation based on AMQP (Advanced Message Queue) protocol developed by erlang. It is used to store and forward messages in a distributed system, and is excellent in terms of ease of use, scalability, and high availability. Is currently one of the most mainstream messaging middleware.

RabbitMQ's official website: http://www.rabbitmq.com

 

2. AMQP

AMQP, an open standard for application layer protocols, is designed for message-oriented middleware. Message middleware is mainly used for decoupling between components. The sender of the message does not need to know the existence of the message user. Similarly, the message user does not need to know the existence of the sender. The main characteristics of AMQP are message-oriented, queue, routing (including point-to-point and publish/subscribe), reliability, and security.

 

3. System architecture

As shown in the figure above:

  • There are two main components in AMQP: Exchange and Queue;
  • The green X is Exchange, the red square is Queue, both of which are on the Server side, also called Broker, this part is implemented by RabbitMQ;
  • The blue one is the client, which usually has two types: Producer and Consumer;

RabbitMQ workflow:

  1. [Open channel] The client connects to the message queue server and opens a Channel ;
  2. [Declare Exchange] The client declares an Exchange and sets related attributes;
  3. [Declare message queue] The client declares a Queue and sets related properties;
  4. [Binding] switches and queue clients to use routing Key , the Exchange and Queue establish a good relationship between the binding;
  5. [Message Delivery] The client delivers the message to Exchange . After the Exchange receives the message, it will route the message according to the Routing Key of the message  and the Binding that has been set  , and deliver the message to one or more queues;

Note: A consumer can only consume one message (if repeated declarations, the type parameter remains unchanged, no error will be reported. If there is a change between the second declaration and the first type parameter, an exception will be reported);

 

4. Basic concepts

  • Producer: Producer, sender of data;
  • Consumer: Consumer, the recipient of the data;
  • Exchange: Message exchange, which specifies the rules and queues to which messages are routed;
  • Queue: message queue carrier, each message will be put into one or more queues;
  • Binding: binding, its role is to bind exchange and queue according to routing rules;
  • Routing Key: routing key, exchange carries out message delivery according to this key;
  • vhost: virtual host (default "/"), multiple vhosts can be set up in a Broker to separate the permissions of different users;
  • Channel: Message channel. In each connection of the client, multiple Channels can be established, and each Channel represents a session task;

 

Guess you like

Origin blog.csdn.net/ChaITSimpleLove/article/details/106035197