The channelMax limit is reached. Try later.顾名思义就是channel达到数量限制
查看源码得出
大概意思就是:
默认最大通道数;2047,因为它在服务器端是第2048个,每个连接用于协商和错误通信。
也可以在rabbitmq的管控台看出
总结:一个客户端连接(一个服务)默认只能有2047个通道数,也就是2047个消费者,在高并发的情况可能不够用,其实这个数字是可以修改。修改步骤如下:
第一:
创建rabbitmq配置文件rabbitmq.conf
default_user = guest
default_pass = guest
#最大通道数量
channel_max = 6114
第二:关闭rabbitmq镜像服务
docker stop 镜像名/镜像id
docker stop rabbitmq
第三:移除rabbitmq镜像服务
docker rm 镜像名/镜像id
docker rm rabbitmq
第四:启动rabbitmq镜像服务
docker run -d --name rabbitmq \
-p 5673:5672 \
-p 15673:15672 \
-v /etc/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf \
-e RABBITMQ_CONFIG_FILE=/etc/rabbitmq/rabbitmq.conf \
--restart=always \
rabbitmq:3.11.1-management
第五:在消费者服务配置,不配置不生效
具体配置如下:
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author leishen
*/
@Configuration
public class RabbitMQConfiguration {
@Value("${spring.rabbitmq.username}")
private String username;
@Value("${spring.rabbitmq.password}")
private String password;
@Value("${spring.rabbitmq.host}")
private String host;
@Value("${spring.rabbitmq.port}")
private Integer port;
@Value("${spring.rabbitmq.virtual-host}")
private String virtualHost;
/**
* 设置最大通道数
* @return
*/
@Bean
public CachingConnectionFactory cachingConnectionFactory(){
CachingConnectionFactory cachingConnectionFactory=new CachingConnectionFactory();
com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = cachingConnectionFactory.getRabbitConnectionFactory();
//默认2047
rabbitConnectionFactory.setRequestedChannelMax(6114);
rabbitConnectionFactory.setUsername(username);
rabbitConnectionFactory.setPort(port);
rabbitConnectionFactory.setHost(host);
rabbitConnectionFactory.setVirtualHost(virtualHost);
rabbitConnectionFactory.setPassword(password);
return cachingConnectionFactory;
}
}
第六:打开管控台查看,结果配置生效