Skip to content

Commit

Permalink
GH-1477: Reduce Log Noise While Broker Down
Browse files Browse the repository at this point in the history
Resolves #1477

Only log the stack trace on the first failure.

Tested with a Boot app and stop/start/stop the broker.

**cherry-pick to 2.4.x**
  • Loading branch information
garyrussell authored and artembilan committed Oct 21, 2022
1 parent 2a4a0ec commit 77dfa65
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import org.aopalliance.aop.Advice;
Expand Down Expand Up @@ -147,6 +148,8 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor

private ContainerDelegate proxy = this.delegate;

private final AtomicBoolean logDeclarationException = new AtomicBoolean(true);

private long shutdownTimeout = DEFAULT_SHUTDOWN_TIMEOUT;

private ApplicationEventPublisher applicationEventPublisher;
Expand Down Expand Up @@ -1960,12 +1963,18 @@ protected synchronized void redeclareElementsIfNecessary() {
if (!this.lazyLoad && admin != null && isAutoDeclare()) {
try {
attemptDeclarations(admin);
this.logDeclarationException.set(true);
}
catch (Exception e) {
if (RabbitUtils.isMismatchedQueueArgs(e)) {
throw new FatalListenerStartupException("Mismatched queues", e);
}
logger.error("Failed to check/redeclare auto-delete queue(s).", e);
if (this.logDeclarationException.getAndSet(false)) {
this.logger.error("Failed to check/redeclare auto-delete queue(s).", e);
}
else {
this.logger.error("Failed to check/redeclare auto-delete queue(s).");
}
}
}
}
Expand Down

0 comments on commit 77dfa65

Please sign in to comment.