RabbitMQ of Connection and Channel

We know that both producers and consumers, we need to establish a connection and RabbitMQ Broker, this connection is a TCP connection, which is Connection.

Once a TCP connection is established, the client can immediately create a AMQP channel (Channel), each channel will be assigned a unique ID.

Channel Connection is based on the virtual connection, each instruction RabbitMQ AMQP process is accomplished by channel.

 

We can use the Connection to complete the work of the channel, why does introduction channel?

Imagine a scenario where an application has many threads need to consume messages from RabbitMQ, or in the production of news, then the inevitable need to establish a number of Connection, that is, multiple TCP connections.

However, to the operating system, TCP connection is created and destroyed very expensive overhead, if they use a peak performance bottlenecks also will appear.

RabbitMQ similar NIO (Non-blocking I / O) this selected TCP connection multiplexing, not only can reduce the performance overhead, but also easy to manage.

 

Each gripping a thread channel, the channel multiplexing of Connection TCP connection. Meanwhile RabbitMQ can ensure the privacy of each thread, just as connected as an independent. When the flow rate of each channel is not large, the complex can effectively save resources in the case of TCP connections create a performance bottleneck of a single Connection. However, when the flow channel itself is large, this time using a plurality of channels multiplexed Connection will create a performance bottleneck, and thus the overall flow rate is limited. In this case it is necessary to open up a plurality of Connection, these channels are evenly distributed among these Connection, as these related tuning adjustment is required according to the service policy to their actual situation.

 

Channel is a very important concept in AMQP, most operations are deployed at this level of the channel.

比如 channel.exchangeDeclare、channel.queueDeclare、channel.basicPublish、channel.basicConsume 等方法。

RabbitMQ AMQP related closely to the API, such as corresponding to the AMQP Basic.Publish channel.basicPublish command.

Guess you like

Origin www.cnblogs.com/yunianzeng/p/12483706.html