The message contains two parts: 1. payload-the data you want to transmit. 2. lable-describes information about a payload, including the specific switch and recipient of the message.
The basic process of rabbitmq is as follows:
The client and server of rabbitmq communicate with the rabbitmq server through a channel.
Channel: the connection between the program and rabbitmq is through the channel, and the channel is based on the TCP protocol ?, A TCP connection can have multiple channels, which are similar to the following: a large cable contains many small wires. A large cable is a TCP connection and a small wire is a channel, why is this design necessary? Because the system creates and destroys TCP connections, multiple non-conflicting communication operations on one TCP can greatly increase the efficiency.
The message routing of amqp must contain three parts:Exchange, queue, bind).
1. Queue (Queue):The place where messages are stored and waiting for consumers to obtain them. Consumers can receive messages from queue in the following two ways.
(1) subscribe through amqp's basic. Consume command. In this way, the channel is set to the receiving mode until the queue subscription is canceled. After subscribing to a message, the consumer can automatically receive the next message from the queue (available) after consuming (or rejecting) The message recently received.In this subscription mode, after the producer publishes a message to the queue, the message is automatically received by the consumer..
(2) Use the basic. GET command of amqp to obtain the Next message. In this mode, only one message is obtained at a time, and the subscription is canceled. If you want to continue obtaining the next message, you need to send this command again. Note: Basic. Get should not be used in the for loop to replace basic. Consume, which will affect the performance of rabbit.
Exchange (switch): the router for the message, the label for parsing the message (lable)
Rabbitmq Study Notes 2-Understanding messaging