Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

An endless loop when adjust consumers in DirectReplyToMessageListenerContainer #2760

Closed
AlNadraga opened this issue Jul 17, 2024 · 2 comments

Comments

@AlNadraga
Copy link

Version: 2.4.17

Describe the bug

When the application starts, a message is sent to another service. During the start, the Rabbitmq broker crashed and the application began to write endlessly to the log line until it ran out of disk space. The line was written to the log is DEBUG(org.springframework.amqp.rabbit.listener.DirectReplyToMessageListenerContainer): Consume from queue amq.rabbitmq.reply-to ignore, container stopping

To Reproduce

Unfortunately, this problem has occurred twice in half a year and I can't say for sure how it can be reproduced. But as far as I understand, this happens in the method DirectMessageListenerContainer#adjustConsumers in the method inside the loop while (this.consumersByQueue.get(queue) == null || this.consumersByQueue.get(queue).size() < newCount) . If we put a breakpoint there and set the container (this.active == false), then we are stuck in an endless loop.

Expected behavior

If the container is not active, then as far as I understand, we should not try to specify the number of consumers. At least in this situation, the thread should not hang in an endless loop.

@artembilan
Copy link
Member

Yeah, totally agreed on the problem.
So, when we enter this loop, we exit immediately from the doConsumeFromQueue:

	private void doConsumeFromQueue(String queue, int index) {
		if (!isActive()) {
			if (this.logger.isDebugEnabled()) {
				this.logger.debug("Consume from queue " + queue + " ignore, container stopping");
			}
			return;
		}

And since we don't "really adjust" those consumers, we come back to the beginning of that while().

I guess we need to fix it like this:

while (isActive() && ...

To check for working state on every iteration.

Note: the version 2.4.x is out of Open Source support: https://spring.io/projects/spring-amqp#support.
So, even if we fix it, it is not going to make to that version.
Therefore you need to start thinking about upgrading your solution to newer versions of Spring projects.

@artembilan artembilan added this to the 3.2.0-M2 milestone Jul 17, 2024
spring-builds pushed a commit that referenced this issue Jul 30, 2024
Fixes: #2760

When the application starts, a message is sent to another service.
During the start, the Rabbitmq broker crashed and the application began to write endlessly to the log line until it ran out of disk space.
The line was written to the log is `DEBUG(org.springframework.amqp.rabbit.listener.DirectReplyToMessageListenerContainer): Consume from queue amq.rabbitmq.reply-to ignore, container stopping`

(cherry picked from commit dd6a171)
@artembilan
Copy link
Member

Since you don't answer, I decided to go ahead and incorporate the fix we have talked before.
Thanks

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants