Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/core kafka exceptions #69

Merged
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.f_lab.la_planete.core.kafka.aspect;

import com.f_lab.la_planete.core.kafka.exceptions.NonRetryableException;
import com.f_lab.la_planete.core.exceptions.ApplicationException;
import com.f_lab.la_planete.core.exceptions.ErrorCode;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
Expand All @@ -24,21 +25,18 @@ public Object kafkaRetry(ProceedingJoinPoint joinPoint) {
while(attempt < MAX_RETRY) {
try {
return joinPoint.proceed();
} catch (NonRetryableException e) {
throw e;

} catch (Throwable e) {
log.warn("시도 횟수={}, 메서드={}", attempt, joinPoint.getSignature());
attempt++;

try {
Thread.sleep(STOP_INTERVAL);
} catch (InterruptedException ex) {
throw new NonRetryableException(ex);
throw new ApplicationException(ErrorCode.KAFKA_RETRY_FAIL_EXCEPTION, ex);
}
}
}

throw new NonRetryableException("오류 발생! 잠시 후 다시 시도해주세요.");
throw new ApplicationException(ErrorCode.KAFKA_RETRY_FAIL_EXCEPTION);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
package com.f_lab.la_planete.core.kafka.exceptions;

public class NonRetryableException extends RuntimeException {

public NonRetryableException() {
}
import com.f_lab.la_planete.core.exceptions.ApplicationException;

public NonRetryableException(String message) {
super(message);
}

public NonRetryableException(String message, Throwable cause) {
super(message, cause);
}

public NonRetryableException(Throwable cause) {
super(cause);
}

public NonRetryableException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public class NonRetryableException extends ApplicationException {
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
package com.f_lab.la_planete.core.kafka.exceptions;

public class RetryableException extends RuntimeException {

public RetryableException() {
}

public RetryableException(String message) {
super(message);
}

public RetryableException(String message, Throwable cause) {
super(message, cause);
}

public RetryableException(Throwable cause) {
super(cause);
}

public RetryableException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
Loading