Skip to content

Bug: PaymentKafkaConsumer 중복 파일 삭제 및 수정#54

Merged
juyeonbaeck merged 2 commits intomainfrom
bug/kafkaconsumer
Feb 4, 2026
Merged

Bug: PaymentKafkaConsumer 중복 파일 삭제 및 수정#54
juyeonbaeck merged 2 commits intomainfrom
bug/kafkaconsumer

Conversation

@juyeonbaeck
Copy link
Contributor

@juyeonbaeck juyeonbaeck commented Feb 4, 2026

💡 PR 작업 내용

  • 기능 관련 작업
  • 버그 수정
  • 코드 개선 및 수정
  • 문서 작성
  • 배포
  • 브랜치
  • 기타 (아래에 자세한 내용 기입해 주세요)

📋 세부 작업 내용

  • 쿠폰 서비스, 디렉토리 구조 변경

📸 작업 화면 (스크린샷)

💬 리뷰 요구사항(선택)

⚠️ PR하기 전에 확인해 주세요.

  • 로컬테스트를 진행하셨나요?
  • 머지할 브랜치를 확인하셨나요?
  • 관련 label을 선택하셨나요?

⭐ 관련 이슈 번호

🖇️ 기타

Summary by CodeRabbit

릴리스 노트

  • Chores

    • 개발/테스트용 API 엔드포인트 제거
  • Refactor

    • 결제 메시지 처리 로직 통합 및 재구성
    • 결제 성공/실패 처리 개선 및 환불(보상) 흐름 강화
    • 메시지 수신 처리에 트랜잭션 적용으로 일관성·복원력 향상

@juyeonbaeck juyeonbaeck linked an issue Feb 4, 2026 that may be closed by this pull request
@juyeonbaeck juyeonbaeck self-assigned this Feb 4, 2026
@juyeonbaeck juyeonbaeck added the 🐛 bug 오류 수정 시 label Feb 4, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

중복된 PaymentConsumer를 제거하고 처리 로직을 PaymentKafkaConsumer로 통합했습니다. TestController(개발/테스트용 Kafka 엔드포인트)는 삭제되었고, PaymentKafkaConsumer는 원시 문자열 메시지를 수신해 JSON으로 파싱한 뒤 트랜잭션 내에서 성공/실패 보정 로직을 수행하도록 리팩터링되었습니다.

Changes

Cohort / File(s) Summary
워크플로우 설정
\.github/workflows/deploy-aws-point.yml
경로 필터 주석을 중립적 설명으로 변경 (주석만 수정, 기능적 변경 없음).
삭제된 테스트 컴포넌트
cloud-services/msa-point-service/src/main/java/com/techsemina/msa/pointservice/controller/TestController.java
dev/test 프로필용 Kafka 테스트 REST 컨트롤러 제거 (엔드포인트: POST /test/fake-success, POST /test/fake-fail).
Kafka Consumer 통합 및 리팩터링
cloud-services/msa-point-service/src/main/java/com/techsemina/msa/pointservice/kafka/PaymentKafkaConsumer.java
리스너 시그니처를 객체 → String message로 변경, ObjectMapper로 JSON 파싱 추가, @Transactional 적용, 성공 시 paymentService.completePayment(orderId) 호출, 실패 시 PaymentRepository 조회·보정(중복 처리 방지, 보상 호출, 상태 업데이트) 로직으로 재구성.
삭제된 중복 Consumer
cloud-services/msa-point-service/src/main/java/com/techsemina/msa/pointservice/service/PaymentConsumer.java
기존 Kafka 리스너 클래스(문자열 파싱·보정 로직 포함) 제거 — 기능이 PaymentKafkaConsumer로 통합됨.

Sequence Diagram(s)

sequenceDiagram
  participant Kafka as Kafka Broker
  participant Consumer as PaymentKafkaConsumer
  participant JSON as ObjectMapper
  participant Service as PaymentService
  participant Repo as PaymentRepository/DB

  Kafka->>Consumer: 메시지(문자열) 전송
  Consumer->>JSON: 문자열 -> CashResponseDTO 변환
  alt status == "SUCCESS"
    Consumer->>Service: completePayment(orderId)
  else status != "SUCCESS"
    Consumer->>Repo: findByOrderId(orderId)
    Repo-->>Consumer: Payment (or not found)
    alt payment not PENDING
      Consumer-->>Kafka: 처리 중단 (중복)
    else
      Consumer->>Service: compensatePayment(orderId)
      Consumer->>Repo: 상태 -> FAILED (dirty checking로 커밋)
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Poem

안녕한 서비스, 중복은 사라지고,
메시지는 문자열로 춤을 추네.
트랜잭션 안에서 보정하고,
로그엔 조용히 성공을 적고,
흐름은 깔끔히 통합되었네. ☕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 설명합니다: 중복된 PaymentKafkaConsumer 파일 삭제 및 수정이라는 실제 변경사항을 정확하게 반영하고 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/kafkaconsumer

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@cloud-services/msa-point-service/src/main/java/com/techsemina/msa/pointservice/kafka/PaymentKafkaConsumer.java`:
- Around line 46-59: The current consumer in PaymentKafkaConsumer checks only
for "FAILED" and may overwrite other terminal states; change the guard to
proceed only when payment.getStatus() equals "PENDING" so
compensatePayment(payment.getOrderId()) and
payment.setStatus("FAILED")/paymentRepository.save(payment) run exclusively for
pending payments; locate the logic around payment.getStatus(),
paymentService.compensatePayment(...) and paymentRepository.save(...) and
replace the "FAILED" check with an explicit "PENDING" check (or return unless
status == "PENDING") to avoid transitioning COMPLETED or other states to FAILED.
- Around line 29-33: The call to objectMapper.readValue in PaymentKafkaConsumer
can throw Jackson exceptions that, when uncaught, cause infinite
retry/poison-message loops; wrap the deserialization in a try/catch to handle
JsonProcessingException (or IllegalArgumentException) and forward the raw
message to a Dead Letter Topic (use your KafkaTemplate.send from
PaymentKafkaConsumer) or mark it handled instead of rethrowing; alternatively,
configure a KafkaListenerContainerFactory bean to register a DefaultErrorHandler
that treats JsonProcessingException as non-retryable and routes to a DLT (or
uses a DeadLetterPublishingRecoverer) so deserialization failures from
objectMapper.readValue are not retried forever.

@juyeonbaeck juyeonbaeck merged commit e627ef2 into main Feb 4, 2026
1 check passed
@juyeonbaeck juyeonbaeck deleted the bug/kafkaconsumer branch February 4, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug 오류 수정 시

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: PaymentKafkaConsumer 파일 수정

1 participant