相关文章推荐
怕老婆的米饭  ·  NETSDK1004: ...·  1 年前    · 
沉着的脸盆  ·  D3.js ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I know that this error was mentioned in other posts as ( https://github.com/spring-projects/spring-amqp/issues/999 and https://github.com/spring-projects/spring-amqp/issues/853 ) but I haven't found the solution for me.

My project has defined a set of microservices that publishing and consuminng messages by queue. when I run my stress tests with 200 Transaction per seconds I get this error:

The channelMax limit is reached. Try later

This error is only shown in one microservice in the rest no.

I am using in my project:

spring-boot-starter-amqp.2.3.4.RELEASE
 spring-rabbit:2.2.11

and my setting of rabbit is :

  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;

My questions are :

Should I set up the ChannelCacheSize and setChannelCheckoutTimeout?. I did a test increasing the channelCacheSize to 50 but the issue is still happenning. What would it be the best value for these parameters as per I mentioned it earlier?. I read about channelCheckoutTimeout should be higher than 0 but I don't know what value i must set up.

Right now i am processing around 200 Transaction per second but this number will be increased progressly

Thank you in advance.

channel_max is negotiated between the client and server and applies to connections. The default is 2047 so it looks like you broker has imposed a lower limit.

https://www.rabbitmq.com/channels.html#channel-max

When using publisher confirms, returning channels to the cache is delayed until the confirm is received; hence more channels are generally needed when the volume is high.

You can either reconfigure the broker to allow more channels, or change the CacheMode to CONNECTION instead of the default (CHANNEL).

https://docs.spring.io/spring-amqp/docs/current/reference/html/#cachingconnectionfactory

May I ask the reason why you're saying that 2047 is a lower limit ? If I have defined , the limit of 2047 by connection and I can only send messages through that connection, although I receive a lot of messages around 200 messages per second, in one second, I will be able to open 200 channels (one by each message) and I will close the channel in short space of time (miliseconds maybe). How is it possible that my apps is reaching the limit?. Is the max channels, the total of channels (consumers + publishers) between all connections or only for single connection. – Reyfren Jul 29, 2021 at 6:58 I don't recall where I saw the 2047 default. As I said, the limit is negotiated between the client and server; most likely your server has imposed a lower limit. – Gary Russell Jul 29, 2021 at 14:09

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.