Search code examples
javarabbitmqamqpspring-amqp

AMQP consumer(listener adapter + SimpleMessageListenerContainer) holding message


Recently we came across a situation where the messages were taken up from the queue by the consumer but did not reach the listener bound to that queue. We were able to make this assertion because we have an interceptor on our listeners (which prints a log message) that was not triggered for those messages. As soon as we restarted the server(tomcat) the messages were consumed and acked.

We would like to know the reason for such a behavior. We analyzed the thread dumps but with no success.


Solution

  • Such issues are invariably caused by one of two problems:

    • container thread(s) "stuck" in user code
    • some network component (e.g. router) silently closing a connection that it thinks is idle such the the client and/or server is not aware that the connection is closed.

    You seem to have eliminated the first (assuming your analysis is correct) so it's most likely the second.

    You can enable heartbeats on the connection to avoid the network thinking a connection is idle. Refer to the RabbitMQ documentation.