-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat : 주문취소 feign retryer bean 추가 #564
Conversation
@@ -12,7 +12,7 @@ | |||
|
|||
@FeignClient( | |||
name = "PaymentsCancelClient", | |||
url = "https://api.tosspayments.com", | |||
url = "${feign.toss.url}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
가리는거 좋아용
private static final long PERIOD = 100L; | ||
private static final long MAX_PERIOD = TimeUnit.SECONDS.toMillis(3L); | ||
private static final int MAX_ATTEMPTS = 3; | ||
|
||
@Bean | ||
Retryer.Default retryer() { | ||
return new Retryer.Default(PERIOD, MAX_PERIOD, MAX_ATTEMPTS); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호 이런방식으로 하는거군요 배워갑니당
// private final static String IDEMPOTENCY_KEY = "idempotency-key"; | ||
// private final static String PAYMENT_KEY = "1234"; | ||
// private final static CancelPaymentsRequest REQUEST = | ||
// CancelPaymentsRequest.builder().cancelReason("test").build(); | ||
// @Autowired | ||
// private PaymentsCancelClient paymentsCancelClient; | ||
// | ||
// @Test | ||
// public void 주문취소_실패시_멱등성_테스트() { | ||
// final String URL = "/v1/payments/" + PAYMENT_KEY + "/cancel"; | ||
// // given | ||
// stubFor(post(urlEqualTo(URL)) | ||
// .willReturn(aResponse() | ||
// .withStatus(HttpStatus.SERVICE_UNAVAILABLE))); | ||
// | ||
// // when | ||
// Throwable exception = catchThrowable( | ||
// () -> paymentsCancelClient.execute(IDEMPOTENCY_KEY, PAYMENT_KEY, REQUEST)); | ||
// | ||
// // then | ||
// assertThat(exception).isInstanceOf(RetryableException.class); | ||
// verify(3, postRequestedFor(urlEqualTo(URL))); | ||
// } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고민의 흔적....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
비상탈출...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니당
Kudos, SonarCloud Quality Gate passed! |
@Override | ||
public Exception decode(String methodKey, Response response) { | ||
TossPaymentsErrorDto body = TossPaymentsErrorDto.from(response); | ||
try { | ||
PaymentsCancelErrorCode paymentsCancelErrorCode = | ||
FeignException exception = feign.FeignException.errorStatus(methodKey, response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
에러 디코더는 도는게 맞는데
TossPaymentsErrorDto 를 먼저해버려서
응답값 파싱중에
unhandleException 먼저 되버린 문제였습니다!
바디파싱은 뒤로미루고
500 번대 먼저 캐치해서 리트라이 했어요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response 를 먼저 읽어서 그렇군요 확인입니다
개요
작업사항
변경로직