7.1.Channel

予早 2025-02-21 01:08:23
Categories: Tags:

AMQP 0-9-1中在Connection中打开多个channel以复用Connection。

通道存在于连接上下文中,通道之间互相隔离,当连接关闭,连接上打开的通道也会被关闭。

客户端和broker之间使用channel id区分通道

Resource Usage

客户端:部分内存

broker:部分内存+erlang进程

Maximum Number of Channels per Connection

连接上可以同时打开的最大通道数由客户端和服务器在连接时协商。该值对于 RabbitMQ 和客户端库都是可配置的。

server

# no more 100 channels can be opened on a connection at the same time
channel_max = 100

client

ConnectionFactory cf = new ConnectionFactory();
// Ask for up to 32 channels per connection. Will have an effect as long as the server is configured
// to use a higher limit, otherwise the server's limit will be used.
cf.setRequestedChannelMax(32);

Safety

Channel Leak

Channel Churn