-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#64] 결제 실패 흐름 구현 #66
Conversation
@@ -62,6 +64,8 @@ public ConsumerFactory<String, GroupMemberIncreaseRequestDto> groupIncreaseConsu | |||
public ConcurrentKafkaListenerContainerFactory<String, GroupMemberIncreaseRequestDto> groupIncreaseKafkaListenerContainerFactory() { | |||
ConcurrentKafkaListenerContainerFactory<String, GroupMemberIncreaseRequestDto> factory = new ConcurrentKafkaListenerContainerFactory<>(); | |||
factory.setConsumerFactory(groupIncreaseConsumerFactory()); | |||
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL); |
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.
스프링 카프카의 자동 커밋을 해제했습니다. 이유는 다음과 같습니다.
- 결제 완료 후 문제가 생길 경우 동일한 결제 이벤트 처리 가능성 (중복 결제)
- 이벤트 컨슘 후 즉시 커밋함으로써 한 번 진행한 결제 이벤트의 재처리 방지
payService.processPayRequest(dto); | ||
public void listen(GroupMemberIncreaseRequestDto message, Acknowledgment ack) { | ||
// 메시지를 받자마자 이벤트 히스토리 기록 & 커밋하기 | ||
PayEvent payEvent = payEventService.savePayEvent(message); |
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.
결제 이벤트를 수신한 후 히스토리를 남기고 바로 커밋합니다.
이후 실패에 대해선 DB
에 적재된 히스토리를 통해 재시도합니다.
kafkaProducer.send(GROUP_MEMBER_INCREASE_RESPONSE, groupMemberIncreaseMapper.toResponse(dto, status)); | ||
} | ||
// 이벤트 완전 처리 시점 기록 | ||
payEvent.getBaseEvent().setProcessedAt(LocalDateTime.now()); |
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.
결제 성공 후, 결제 성공 이벤트
발행 전 문제가 발생한다면 이벤트 처리 시점이 기록되지 않습니다.
@@ -64,7 +64,7 @@ public ConsumerFactory<String, GroupMemberIncreaseRequestDto> groupIncreaseConsu | |||
public ConcurrentKafkaListenerContainerFactory<String, GroupMemberIncreaseRequestDto> groupIncreaseKafkaListenerContainerFactory() { | |||
ConcurrentKafkaListenerContainerFactory<String, GroupMemberIncreaseRequestDto> factory = new ConcurrentKafkaListenerContainerFactory<>(); | |||
factory.setConsumerFactory(groupIncreaseConsumerFactory()); | |||
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL); | |||
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE); |
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.
MANUAL
옵션의 경우 다음 poll() 시점에 커밋을 진행합니다. 이는 기존 의도와 맞지 않으므로, 즉시 커밋하는 MANUAL_IMMEDIATE
옵션으로 변경하였습니다.
개발 내용
개발 코멘트