Spring boot AMQPSResourceNotAvailableException:已达到channelMax限制。稍后再试

Spring boot AMQPSResourceNotAvailableException:已达到channelMax限制。稍后再试,spring-boot,spring-integration,spring-rabbit,Spring Boot,Spring Integration,Spring Rabbit,我知道这个错误在其他帖子中被称为(和),但我还没有找到适合我的解决方案 我的项目定义了一组微服务,可以按队列发布和使用消息。当我 以每秒200个事务的速度运行压力测试我收到以下错误: 已达到channelMax限制。稍后再试 此错误仅在剩余编号中的一个微服务中显示 我在我的项目中使用: spring-boot-starter-amqp.2.3.4.RELEASE spring-rabbit:2.2.11 我对兔子的设定是: public ConnectionFactory publish

我知道这个错误在其他帖子中被称为(和),但我还没有找到适合我的解决方案

我的项目定义了一组微服务,可以按队列发布和使用消息。当我 以每秒200个事务的速度运行压力测试我收到以下错误:

已达到channelMax限制。稍后再试

此错误仅在剩余编号中的一个微服务中显示

我在我的项目中使用:

spring-boot-starter-amqp.2.3.4.RELEASE
 spring-rabbit:2.2.11
我对兔子的设定是:

  public ConnectionFactory publisherConnectionFactory() {
    final CachingConnectionFactory connectionFactory = new 
    CachingConnectionFactory(rabbitMQConfigProperties.getHost(), rabbitMQConfigProperties.getPort());
    connectionFactory.setUsername(rabbitMQConfigProperties.getUser());
    connectionFactory.setPassword(rabbitMQConfigProperties.getPass());
    connectionFactory.setPublisherReturns(true);
    connectionFactory.setPublisherConfirms(true);
    connectionFactory.setConnectionNameStrategy(connecFact -> rabbitMQConfigProperties.getNameStrategy());
    connectionFactory.setRequestedHeartBeat(15);
    return connectionFactory;
}


@Bean(name = "firstRabbitTemplate")
public RabbitTemplate firstRabbitTemplate(MessageDeliveryCallbackService messageDeliveryCallbackService) {
    final RabbitTemplate template = new RabbitTemplate(publisherConnectionFactory());
    template.setMandatory(true);
    template.setMessageConverter(jsonMessageConverter());
    template.setReturnCallback((msg, i, s, s1, s2) -> {
        log.error("Publisher Unable to deliver the message {} , Queue {}: --------------", s1, s2);
        messageDeliveryCallbackService.returnedMessage(msg, i, s, s1, s2);
    });
    template.setConfirmCallback((correlationData, ack, cause) -> {
        if (!ack) {
            log.error("Message unable to connect Exchange, Cause {}: ack{}--------------", cause,ack);
        }
    });
    return template;
}

我的问题是:

我应该设置ChannelCacheSize和setChannelCheckoutTimeout吗?。我做了一个测试,将channelCacheSize增加到50,但问题仍然存在。根据我前面提到的,这些参数的最佳值是多少?。我了解到channelCheckoutTimeout应该大于0,但我不知道必须设置什么值

现在我每秒处理大约200个事务,但这个数字将逐步增加


提前感谢。

channel_max由客户端和服务器协商,适用于连接。默认值是2047,所以看起来您的经纪人设定了一个下限

当使用publisher-confirms时,将通道返回到缓存的时间延迟,直到收到确认;因此,当音量较大时,通常需要更多的通道

您可以重新配置代理以允许更多通道,或者将
CacheMode
更改为
CONNECTION
,而不是默认的(
CHANNEL