From 23041d4b89e95bd7083620e2373be20a89c2ec5d Mon Sep 17 00:00:00 2001 From: hoa0217 Date: Wed, 17 Apr 2024 19:19:13 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20ListenerExecutionFailedException=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 메시지 처리 도중 발생한 치명적 예외만 ImmediateAcknowledgeAmqpException를 던진다. Related: #70 --- .../config/rabbitmq/errorhandler/CustomErrorHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/modoospace/config/rabbitmq/errorhandler/CustomErrorHandler.java b/src/main/java/com/modoospace/config/rabbitmq/errorhandler/CustomErrorHandler.java index 509a435..4a40aca 100644 --- a/src/main/java/com/modoospace/config/rabbitmq/errorhandler/CustomErrorHandler.java +++ b/src/main/java/com/modoospace/config/rabbitmq/errorhandler/CustomErrorHandler.java @@ -4,6 +4,7 @@ import org.springframework.amqp.AmqpRejectAndDontRequeueException; import org.springframework.amqp.ImmediateAcknowledgeAmqpException; import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy; +import org.springframework.amqp.rabbit.support.ListenerExecutionFailedException; import org.springframework.util.ErrorHandler; @RequiredArgsConstructor @@ -13,7 +14,7 @@ public class CustomErrorHandler implements ErrorHandler { @Override public void handleError(Throwable t) { - if (this.exceptionStrategy.isFatal(t)) { + if (this.exceptionStrategy.isFatal(t) && t instanceof ListenerExecutionFailedException) { throw new ImmediateAcknowledgeAmqpException( "Fatal exception encountered. Retry is futile: " + t.getMessage(), t); }