Working principle and introduction of RabbitMQ

[]Working principle and introduction of [RabbitMQ]

  • Broker : An application that receives and distributes messages, RabbitMQ Server is Message Broker

  • Virtual host : Designed for multi-tenancy and security reasons, divides the basic components of AMQP into a virtual group, similar to the namespace concept in the network. When multiple different users use the services provided by the same RabbitMQ server, multiple vhosts can be divided, and each user creates an exchange/queue in its own vhost, etc.

  • Connection : TCP connection between publisher/consumer and broker

  • Channel : If a Connection is established every time RabbitMQ is accessed, the overhead of establishing a TCP Connection will be huge and the efficiency will be low when the amount of messages is large. Channel is a logical connection established inside the connection . If the application supports multi-threading, usually each thread creates a separate channel for communication. AMQP method contains channel id to help the client and message broker identify the channel, so the channels are completely isolated of. As a lightweight Connection, Channel greatly reduces the overhead of the operating system to establish a TCP connection

    Interview question: Why is rabbitmq based on channel processing instead of connection?
    An application has multiple threads that need to consume or produce messages from rabbitmq. If many Connection connections are established, it is very expensive for the operating system to establish and destroy tcp connections. If the usage peaks, the performance bottleneck will also be Then appear.
    Rabbitmq adopts a nio-like approach, connecting tcp connection multiplexing, which not only reduces performance overhead, but also facilitates management.

  • Exchange : The first station where the message arrives at the broker, according to the distribution rules, matches the routing key in the query table, and distributes the message to the queue. Common types are: direct (point-to-point), topic (publish-subscribe) and fanout (multicast)

  • Queue : The message is finally sent here to wait for the consumer to take it away

  • Binding : The virtual connection between exchange and queue, binding can contain routing key, Binding information is saved in the query table in exchange, which is used for the distribution basis of message

Leave a Comment

Your email address will not be published. Required fields are marked *