Skip to content

[REFACTOR] Retry 처리#19

Merged
unifolio0 merged 2 commits intodevelopfrom
refactor/#18
Feb 12, 2026
Merged

[REFACTOR] Retry 처리#19
unifolio0 merged 2 commits intodevelopfrom
refactor/#18

Conversation

@unifolio0
Copy link
Contributor

closed #18

작업 내용

참고 사항

@unifolio0 unifolio0 self-assigned this Feb 12, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

Warning

Rate limit exceeded

@unifolio0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 57 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/#18

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @unifolio0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 Pull Request는 토스페이먼츠 결제 승인 과정의 안정성을 강화하기 위해 재시도 메커니즘을 도입합니다. Spring Retry 라이브러리를 활용하여 특정 오류 발생 시 자동으로 결제 승인 요청을 재시도하도록 구현하였으며, 멱등성 키를 통해 중복 요청으로 인한 문제를 방지합니다. 이를 통해 네트워크 불안정이나 일시적인 서버 오류로 인한 결제 실패를 줄이고 사용자 경험을 개선하는 것을 목표로 합니다.

Highlights

  • Spring Retry 라이브러리 도입: 결제 승인 과정의 안정성을 높이기 위해 Spring Retry 라이브러리를 프로젝트에 추가했습니다.
  • 토스페이먼츠 결제 승인 재시도 로직 적용: 토스페이먼츠 결제 승인 API 호출 시 발생하는 특정 오류(5xx 서버 에러, 네트워크 접근 오류, 409 Conflict)에 대해 자동으로 재시도하도록 로직을 구현했습니다.
  • 멱등성 키(Idempotency-Key) 활용: 재시도 시 중복 요청으로 인한 문제를 방지하기 위해 각 결제 승인 요청에 고유한 멱등성 키를 생성하여 HTTP 헤더에 포함하도록 변경했습니다.
  • 커스텀 재시도 정책 및 백오프 전략 설정: 재시도 횟수(최대 3회)와 재시도 간격(지수 백오프)을 정의하는 커스텀 재시도 정책을 구성하여 효율적인 재시도를 가능하게 했습니다.
  • 재시도 시나리오 테스트 강화: 재시도 성공 및 실패, 비재시도성 오류 처리 등 다양한 재시도 관련 시나리오를 검증하는 테스트 코드를 추가하고 기존 테스트를 업데이트했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • external/src/main/java/com/samhap/kokomen/payment/external/TosspaymentsClient.java
    • confirmPayment 메서드에 멱등성 키 파라미터 추가 및 HTTP 헤더에 적용
  • internal/build.gradle
    • spring-retry 의존성 추가
  • internal/src/main/java/com/samhap/kokomen/global/config/RetryConfig.java
    • 토스페이먼츠 결제 승인 재시도에 대한 RetryTemplate 빈을 정의
  • internal/src/main/java/com/samhap/kokomen/global/config/TosspaymentsConfirmRetryPolicy.java
    • HttpServerErrorException, ResourceAccessException, 그리고 409 상태 코드의 HttpClientErrorException에 대해 재시도하는 커스텀 재시도 정책을 구현
  • internal/src/main/java/com/samhap/kokomen/payment/service/PaymentFacadeService.java
    • confirmPayment 메서드에 RetryTemplate을 적용하여 재시도 로직을 통합하고, 멱등성 키를 생성하여 사용
    • 409 에러(IDEMPOTENT_REQUEST_PROCESSING) 처리 로직 추가
  • internal/src/test/java/com/samhap/kokomen/payment/service/PaymentFacadeServiceTest.java
    • confirmPayment 메서드의 변경된 시그니처에 맞춰 기존 테스트를 수정
    • 재시도 성공 및 실패 시나리오를 검증하는 새로운 테스트 케이스를 추가
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Test Results

28 tests   28 ✅  14s ⏱️
 5 suites   0 💤
 5 files     0 ❌

Results for commit 0682088.

♻️ This comment has been updated with latest results.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

결제 승인 요청에 대한 재시도 로직을 spring-retry를 사용하여 구현한 점이 좋습니다. 멱등성 키를 사용하여 재시도 시 발생할 수 있는 중복 처리 문제를 방지한 것도 올바른 접근입니다. 전반적으로 좋은 리팩토링이며, 코드의 안정성을 높이는 데 기여할 것입니다. 몇 가지 유지보수성 및 설정 유연성 개선을 위한 제안을 드립니다.

Comment on lines 15 to 22
TosspaymentsConfirmRetryPolicy retryPolicy = new TosspaymentsConfirmRetryPolicy(3);
retryTemplate.setRetryPolicy(retryPolicy);

ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
backOffPolicy.setInitialInterval(500);
backOffPolicy.setMultiplier(2.0);
backOffPolicy.setMaxInterval(2000);
retryTemplate.setBackOffPolicy(backOffPolicy);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

재시도 관련 설정값(최대 시도 횟수, 초기 간격, 증가율, 최대 간격)이 하드코딩되어 있습니다. 이 값들을 application.yml과 같은 외부 설정 파일로 옮기고 @Value 어노테이션을 사용하여 주입받는 것을 권장합니다. 이렇게 하면 애플리케이션 재빌드 없이 각 환경에 맞게 설정을 유연하게 변경할 수 있습니다.

예시:

@Configuration
public class RetryConfig {

    @Value("${retry.tosspayments.max-attempts:3}")
    private int maxAttempts;

    @Value("${retry.tosspayments.initial-interval:500}")
    private long initialInterval;

    @Value("${retry.tosspayments.multiplier:2.0}")
    private double multiplier;

    @Value("${retry.tosspayments.max-interval:2000}")
    private long maxInterval;

    @Bean
    public RetryTemplate tosspaymentsConfirmRetryTemplate() {
        // ...
        TosspaymentsConfirmRetryPolicy retryPolicy = new TosspaymentsConfirmRetryPolicy(maxAttempts);
        // ...
        backOffPolicy.setInitialInterval(initialInterval);
        // ...
    }
}

Comment on lines 58 to 59
log.warn("토스페이먼츠 결제 승인 재시도 {}/2회, paymentKey = {}",
context.getRetryCount(), request.paymentKey());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

로그 메시지에 재시도 횟수가 2회로 하드코딩되어 있습니다. RetryConfig에서 재시도 횟수가 변경될 경우 이 로그는 올바르지 않은 정보를 나타내게 됩니다. 전체 재시도 횟수를 보여주지 않거나, RetryTemplate에서 최대 시도 횟수를 동적으로 가져와 로깅하는 것을 고려해 보세요. 여기서는 전체 횟수를 제거하는 간단한 수정을 제안합니다.

Suggested change
log.warn("토스페이먼츠 결제 승인 재시도 {}/2회, paymentKey = {}",
context.getRetryCount(), request.paymentKey());
log.warn("토스페이먼츠 결제 승인 재시도 {}회차, paymentKey = {}",
context.getRetryCount(), request.paymentKey());

@unifolio0 unifolio0 merged commit 7e210e8 into develop Feb 12, 2026
5 checks passed
@unifolio0 unifolio0 deleted the refactor/#18 branch February 12, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] Retry 처리

1 participant