Skip to content

[feat] PB-79 이메일 인증 비동기 발송 및 재시도 로직 구현 - #170

Merged
PHJ2000 merged 13 commits into
mainfrom
feat/PB-79-async-email-verification-retry
Feb 4, 2026
Merged

PHJ2000 merged 13 commits into
mainfrom
feat/PB-79-async-email-verification-retry

Conversation

@geonusp

@geonusp geonusp commented Jan 29, 2026 •

Copy link
Copy Markdown
Collaborator

✨ Feature PR

🔗 이슈 링크 (필수)

PR 제목: [feat] PB-79 이메일 인증 비동기 발송 및 재시도 로직 구현


🧩 이 PR의 변경사항 (필수)

전체 중 위치 (Stacked PR 시)

  • 전체 이슈 #XXX의 X/X 단계
  • 선행 PR: #XXX (머지 필요)
  • 후속 PR: #XXX (블로킹)

이 PR에서 변경한 것

백엔드:

  • AsyncEmailService 신규 생성: 이메일 비동기 발송 및 재시도 로직 담당
  • EmailVerificationService에서 @Async/@Retryable 로직 분리
    • Spring AOP 프록시 우회 문제 해결 (같은 클래스 내부 호출 시 @async 무시)
  • @Retryable 설정: maxAttempts=4, 재시도 간격 5초→10초→20초
  • @Recover 메서드 구현: 3회 재시도 실패 시 ERROR 로그 기록

프론트엔드:

  • ResendEmailButton 컴포넌트 신규 생성
    • 3분 쿨다운 타이머 (localStorage 기반 상태 유지)
    • 실시간 카운트다운 표시
    • 에러 처리 (쿨다운 위반, 네트워크 오류)
  • SignupEmailSentView 컴포넌트 신규 생성
    • 회원가입 후 이메일 발송 안내 화면
    • ResendEmailButton 통합
  • AuthView 수정: 회원가입 성공 시 SignupEmailSentView 표시
  • auth.ts API 추가: resendVerification() (POST /api/auth/resend-verification)

✅ 이 PR이 커버하는 AC (필수)

Covers (이 PR에서 완료)

  • AC1: 회원가입 API 응답 시간이 1초 이내
  • AC2: 이메일 발송 실패 시 5초, 10초, 20초 간격으로 재시도 (최대 3회)
  • AC3: 재시도 3회 실패 시 @recover 메서드에서 로그 기록
  • AC4: 비동기 발송 중에도 회원가입은 201 Created 반환

Not covered (후속 작업)

  • AC3: (이유: ) → PR #XXX 또는 이슈 #XXX
  • AC4: (이유: ) → PR #XXX 또는 이슈 #XXX

🧪 테스트 결과 (필수)

로컬

./gradlew test
  • ✅/❌ 결과: 성공

CI

  • (자동 첨부)

수동 테스트

AC1: 회원가입 API 응답 시간 1초 이내

  • 시나리오:

    1. 회원가입 API 호출 (POST /api/auth/signup)
    2. 응답 시간 측정
    3. 로그에서 비동기 스레드 확인
  • 결과:
    전

image 후 image
- ✅ HTTP 201 Created (응답 시간: 416ms)                                                                   
- ✅ 로그에 `[email-1]` 스레드명 확인 (비동기 실행)                                                        

AC2: 이메일 발송 실패 시 재시도 간격 (5초→10초→20초)

  • 시나리오:

    1. SMTP 서버를 invalid로 설정
    2. 회원가입 후 로그 모니터링
    3. 재시도 간격 확인
  • 결과:

image image
- ✅ 총 4회 시도 (최초 1회 + 재시도 3회)                                                                   
- ✅ 재시도 간격: 5초 → 10초 → 20초 확인                                                                   

AC3: 재시도 3회 실패 시 @recover 로그 기록

  • 시나리오:

    1. AC2 완료 후 약 40초 대기
    2. ERROR 로그 확인
  • 결과:

image image
- ✅ ERROR 레벨 로그 "이메일 발송 최종 실패 (3회 재시도 완료)" 확인                                        
- ✅ MailSendException 스택 트레이스 포함                                                                  

AC4: 비동기 발송 중에도 201 반환

  • 시나리오:

    1. 회원가입 API 호출
    2. 응답 시간이 SMTP 타임아웃 영향 안 받는지 확인
  • 결과:

image image image
- ✅ HTTP 201 Created (응답 시간: 648ms < 1초)                                                             
- ✅ DB에 User 즉시 저장                                                                                   
- ✅ 이메일 발송은 백그라운드 처리

🧭 영향 범위 체크 (필수)

  • API 변경 (요약: )
  • DB 변경 (마이그레이션: )
  • 설정 변경 (항목: )
  • Breaking change (무엇: )

💬 리뷰 포인트 (필수)

집중해서 볼 파일/라인:

백엔드:

  • AsyncEmailService.java:54-59 - @retryable 설정 (maxAttempts=4의 의미)
    • maxAttempts = 최초 1회 + 재시도 3회 = 총 4회
    • backoff: delay=5000, multiplier=2 → 5초, 10초, 20초
  • AsyncEmailService.java:78-83 - @recover 메서드 시그니처
    • 파라미터 순서 중요: (Exception, 원본 파라미터...)
  • EmailVerificationService.java:32,67,115 - AsyncEmailService 주입 및 호출
    • 별도 클래스로 분리하여 Spring AOP 프록시 정상 작동

프론트엔드:

  • ResendEmailButton.tsx:24-33 - localStorage 기반 쿨다운 복원 로직
    • 페이지 새로고침 시에도 쿨다운 유지
  • ResendEmailButton.tsx:40-64 - 에러 처리 (쿨다운 위반, 네트워크 오류)
    • 서버 400 응답 시 쿨다운 강제 설정
  • AuthView.tsx:189-199 - 조건부 렌더링 (showEmailSent)
    • 회원가입 성공 → SignupEmailSentView 표시
  • auth.ts:121-128 - resendVerification API
    • fetch API 사용 (프로젝트 표준)

트레이드오프/대안:

백엔드:

  • 선택한 방법: 별도 서비스 클래스로 분리 (AsyncEmailService)
  • 대안: Self-injection (@lazy로 자기 자신 주입)
  • 이유: 단일 책임 원칙 준수, 재사용성, 테스트 용이성

프론트엔드:

  • 선택한 방법: localStorage 기반 쿨다운 상태 유지
  • 대안: 서버에서 마지막 발송 시각 조회
  • 이유: 서버 부하 감소, 네트워크 요청 최소화, 빠른 UX

- threaddump 추가
- Spring Retry 라이브러리 추가 (지수 백오프)
- emailTaskExecutor 전용 스레드풀 생성 (core:3, max:6)
- @async + @retryable로 비동기 발송 (최대 3회 재시도)
- @recover로 최종 실패 처리
- 회원가입 API 응답 속도 개선
@geonusp geonusp self-assigned this Jan 29, 2026
@coderabbitai

coderabbitai Bot commented Jan 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/PB-79-async-email-verification-retry

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • ✨ 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Failure to add the new IP will result in interrupted reviews.


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.

 Why:
  - 회원가입 후 이메일 미수신 시 사용자가 직접 재전송 요청 가능
  - 비동기 이메일 발송으로 인한 사용자 혼란 방지

  What:
  - ResendEmailButton: 재전송 버튼 (3분 쿨다운 타이머)
  - SignupEmailSentView: 이메일 발송 안내 화면
  - AuthView: 회원가입 성공 시 안내 화면 표시
  - auth.ts: resendVerification API 추가

  How:
  - localStorage 기반 쿨다운 상태 유지 (페이지 새로고침 대응)
  - fetch API로 POST /api/auth/resend-verification 호출
  - 에러 처리 (쿨다운 위반, 네트워크 오류)
  - 접근성 지원 (aria-label, aria-busy, role="alert")
@geonusp geonusp changed the title Feat/pb 79 async email verification retry [feat] PB-79 이메일 인증 비동기 발송 및 재시도 로직 구현 Jan 30, 2026
- Spring AOP 프록시 우회 문제 해결을 위해 @Async/@retryable 로직을 별도 서비스로 분리
- AsyncEmailService: 이메일 비동기 발송 및 SMTP 장애 시 자동 재시도 담당 (5초→10초→20초)
- resendVerification 버그 수정: rawToken 대신 verificationLink 전달
- EmailSender, fromAddress 불필요한 의존성 제거"
- 최초 1회 + 재시도 3회 = 총 4회로 수정
@PHJ2000
PHJ2000 self-requested a review January 30, 2026 05:34

@PHJ2000 PHJ2000 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

수고하셨습니다. 몇 가지 사항만 고치면 될 거 같습니다.

Comment thread src/main/resources/application.yml Resolved
Comment thread build.gradle Resolved
- spring-boot-starter-aop 추가
- @async 직접 호출 시 커밋 전 발송 가능한 정합성 문제 해결
- @TransactionalEventListener(AFTER_COMMIT) 패턴 적용
- EmailVerificationEvent (record), EmailEventListener 신규 구현
- EmailVerificationService: asyncEmailService 직접 호출 → eventPublisher로 변경
@PHJ2000
PHJ2000 merged commit 3a4ed08 into main Feb 4, 2026
1 check passed
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.

[feat] PB-79 이메일 인증 비동기 발송 및 재시도 로직 구현

2 participants