Skip to content

Commit 01e4d91

Browse files
authored
GH-3122: Log MessageRejectedWhileStoppingException as info in DMLC
Fixed the issue `MessageRejectedWhileStoppingException` should not lead to an error log in all cases Fixes: #3122 The `MessageRejectedWhileStoppingException` in the `DirectMessageListenerContainer` was always logged at the error level, even though it is expected during an orderly shutdown and does not indicate a real error. Now, when this exception occurs, it is logged at the info level, reducing unnecessary error noise in logs. * In `DirectMessageListenerContainer.callExecuteListener()`, exceptions of type `MessageRejectedWhileStoppingException` are now logged at info level. All other exceptions continue to be logged as errors. Signed-off-by: Madan H K <[email protected]>
1 parent 2823d8d commit 01e4d91

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,12 @@ private void callExecuteListener(Object data, long deliveryTag) { // NOSONAR (co
12231223
handleAck(deliveryTag, channelLocallyTransacted);
12241224
}
12251225
else {
1226-
this.logger.error("Failed to invoke listener", e);
1226+
if (e instanceof org.springframework.amqp.rabbit.listener.exception.MessageRejectedWhileStoppingException) {
1227+
this.logger.info("Listener rejected message while stopping (requeued)", e);
1228+
}
1229+
else {
1230+
this.logger.error("Failed to invoke listener", e);
1231+
}
12271232
if (this.transactionManager != null) {
12281233
if (this.transactionAttribute.rollbackOn(e)) {
12291234
RabbitResourceHolder resourceHolder =

0 commit comments

Comments
 (0)