Skip to content

Commit 2366e92

Browse files
artembilanspring-builds
authored andcommitted
GH-2760: Fix endless loop in the DirectMessageListenerContainer
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)
1 parent 6a0f98a commit 2366e92

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/DirectMessageListenerContainer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ public void addQueues(Queue... queues) {
271271
Assert.noNullElements(queues, "'queues' cannot contain null elements");
272272
try {
273273
Arrays.stream(queues)
274-
.map(Queue::getActualName)
275-
.forEach(this.removedQueues::remove);
274+
.map(Queue::getActualName)
275+
.forEach(this.removedQueues::remove);
276276
addQueues(Arrays.stream(queues).map(Queue::getName));
277277
}
278278
catch (AmqpIOException e) {
@@ -340,8 +340,9 @@ private void adjustConsumers(int newCount) {
340340
checkStartState();
341341
this.consumersToRestart.clear();
342342
for (String queue : getQueueNames()) {
343-
while (this.consumersByQueue.get(queue) == null
344-
|| this.consumersByQueue.get(queue).size() < newCount) { // NOSONAR never null
343+
while (isActive() &&
344+
(this.consumersByQueue.get(queue) == null
345+
|| this.consumersByQueue.get(queue).size() < newCount)) { // NOSONAR never null
345346
List<SimpleConsumer> cBQ = this.consumersByQueue.get(queue);
346347
int index = 0;
347348
if (cBQ != null) {

0 commit comments

Comments
 (0)