user3444718
user3444718

Reputation: 1625

RabbitListener stops processing messages and kind of stuck sometimes

Environment : Spring boot 1.4.0 , RMQ Client : 4.0.1 , CloudFoundry

I have application that has following simple rmq conn factory definition

  @Bean
    public ConnectionFactory connectionFactory() {
        CachingConnectionFactory connectionFactory = new   CachingConnectionFactory();

        connectionFactory.setUsername(user);
        connectionFactory.setPassword(password);
        connectionFactory.setHost(host);
        connectionFactory.setPort(port);
        return connectionFactory;
    }

And simple listener method annotated with @RabbitListener. It works fine. Recently I have noticed couple times that even though I had 5k messages in queue it was not processing. On RMQ admin console I saw it has consumer too. I tried to took thread dump but didnt find anything interesting. Is there anything specially that I should look into thread dump (I have /dump endpoint). This happens anytime, so by the time I will notice logs will be scrolled (if anything) since other traffic like couple simple rest endpoint being invoked time to time. So that tells me that application itself is up, but just this listener part is kind of stuck or hung. I did search on this issue, there were some issues with this but fixed long back. (I don't want to go to pull model please :))

Please advise on how should I troubleshoot this. I have to wait again now to see this issue as I restarted application and it is working fine.

Upvotes: 2

Views: 2743

Answers (1)

Gary Russell
Gary Russell

Reputation: 174584

There is a known problem when the underlying rabbitmq connection factory has autoRecoveryEnabled set to true.

The 4.0.x client library now enables this by default but Spring AMQP doesn't need it; it has always had it's own recovery logic.

It is fixed in 1.6.8 and 1.7.1 (boot 1.4.0 comes with 1.6.1 by default). Boot 1.4.5 comes with 1.6.8.

1.7.1 also disables the option in the 4.0.x client (unless you specifically provide a rabbitmq connection factory).

Boot 1.5.2 comes with 1.7.1 by default.

Options:

  • Upgrade to a newer boot
  • Upgrade to a newer spring-amqp and spring-rabbit jar
  • Turn off autoRecovery in the underlying connection factory.

Upvotes: 2

Related Questions