Skip to content

Commit

Permalink
feature: CustomFatalExceptionStrategy 정의
Browse files Browse the repository at this point in the history
- 심각한 예외인지 판단하는 Straegy를 정의한다.
- 기본적으로 제공해주는 DefaultExceptionStrategy를 데코레이터로 감싸서 NotFoundEntityException과 MessageParsingError를 추가한다.

Related: #70
  • Loading branch information
hoa0217 committed Apr 5, 2024
1 parent 3d63cea commit 35a3508
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.modoospace.config.rabbitmq;

import com.modoospace.common.exception.MessageParsingError;
import com.modoospace.common.exception.NotFoundEntityException;
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler.DefaultExceptionStrategy;
import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy;

public class CustomFatalExceptionStrategy implements FatalExceptionStrategy {

private final FatalExceptionStrategy fatalExceptionStrategy = new DefaultExceptionStrategy();

/**
* 치명적 에러로 간주하고 재처리하지 않는다.
*/
@Override
public boolean isFatal(Throwable t) {
return fatalExceptionStrategy.isFatal(t)
|| t.getCause() instanceof NotFoundEntityException
|| t.getCause() instanceof MessageParsingError;
}
}

0 comments on commit 35a3508

Please sign in to comment.