[FEAT] 공연 : 공연 티켓 예매 Saga 정상 흐름 구현#29
Open
boogiewooki02 wants to merge 3 commits into
Open
Conversation
dldusgh318
approved these changes
May 27, 2026
| if (request == null || request.performanceId() == null) { | ||
| throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "예매할 공연 정보가 필요합니다."); | ||
| } | ||
|
|
| LocalDateTime issuedAt = LocalDateTime.now(); | ||
| reservation.issueQr(ticketQrCodeIssuer.issue(reservation), issuedAt); | ||
| ticketReservationRepository.update(reservation); | ||
| sagaLogs.add(log("QR_ISSUED", "QR 티켓을 발급했습니다.", issuedAt)); |
Owner
There was a problem hiding this comment.
qr 발급이 트랜잭션 내에서 이루어지고 있어, 두 가지 문제가 발생할 수 있을 거 같습니다!
- DB 트랜잭션이 길어져서 락 유지 시간 길어짐
- QR 발급 성공 이후, DB가 실패하면 외부상태와 DB 상태의 불일치
SAGA패턴을 이용해서 분리하는 게 좋을 거 같습니다!
| } | ||
| } | ||
|
|
||
| private TicketReservationSagaLogResponse log( |
Owner
There was a problem hiding this comment.
이거는 따로 record로 분리하는 게 좋을 거 같아요
| null, | ||
| heldAt, | ||
| heldAt)); | ||
| sagaLogs.add(log("SEAT_HELD", "좌석을 선점했습니다.", heldAt)); |
Owner
There was a problem hiding this comment.
여기서 추후 보상 처리 로직도 필요할 거 같습니당
예를 들어..
좌석 선점 해제
QR 폐기
예약 실패 상태 기록
재시도 가능 여부 저장
| private final TicketQrCodeIssuer ticketQrCodeIssuer; | ||
|
|
||
| @Transactional | ||
| public TicketReservationResponse reserveTicket( |
Owner
There was a problem hiding this comment.
현재 로직이 절차적 응집으로 보입니다. 전체적으로 응집도가 낮아보이는데, 추후 보상 처리 로직 등 다양한 로직이 붙으면 더 커질 거 같아, 미리 책임을 분리해두는 걸 추천합니다!
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.
close #
🔎 개요
공연 티켓 예매 Saga 정상 흐름을 구현했습니다.
로그인한 사용자가 공연을 선택한 뒤 좌석 확인, 좌석 선점, 예매 생성, QR 티켓
발급, 예매 완료까지 한 번에 진행할 수 있습니다.
📝 작업 내용
GET /api/performancesGET /api/performances/{performanceId}SEAT_HELDRESERVATION_CREATEDQR_ISSUEDCOMPLETEDCANCELLEDPOST /api/ticket-reservationsGET /api/ticket-reservations/meGET /api/ticket-reservations/{reservationId}/performances/tickets/{reservationId}형태의 티켓 확인 URL 발급👀 변경 사항
SEAT_CHECKED,SEAT_HELD등 내부 Saga 단계는 사용자 화면에 표시하지 않습니다.
sagaLogs가 포함됩니다.✅ 테스트
PerformanceRepositoryTestPerformanceServiceTestTicketReservationControllerTestTicketReservationServiceTestPerformanceCard.test.tsxPerformanceReservationPanel.test.tsx📸 스크린샷 (Optional)