Bug: PaymentKafkaConsumer 중복 파일 삭제 및 수정#54
Merged
juyeonbaeck merged 2 commits intomainfrom Feb 4, 2026
Merged
Conversation
Contributor
📝 WalkthroughWalkthrough중복된 PaymentConsumer를 제거하고 처리 로직을 PaymentKafkaConsumer로 통합했습니다. TestController(개발/테스트용 Kafka 엔드포인트)는 삭제되었고, PaymentKafkaConsumer는 원시 문자열 메시지를 수신해 JSON으로 파싱한 뒤 트랜잭션 내에서 성공/실패 보정 로직을 수행하도록 리팩터링되었습니다. Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Contributor
There was a problem hiding this comment.
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.
...-point-service/src/main/java/com/techsemina/msa/pointservice/kafka/PaymentKafkaConsumer.java
Show resolved
Hide resolved
...-point-service/src/main/java/com/techsemina/msa/pointservice/kafka/PaymentKafkaConsumer.java
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 PR 작업 내용
📋 세부 작업 내용
📸 작업 화면 (스크린샷)
💬 리뷰 요구사항(선택)
⭐ 관련 이슈 번호
🖇️ 기타
Summary by CodeRabbit
릴리스 노트
Chores
Refactor