📌 Outline

<aside> 💡 콘서트 예약 서비스 시나리오 시스템에서 트랜잭션 범위 및 비즈니스 로직 융합에 따른 문제를 EDA 기반으로 개선합니다.

</aside>

🔍 분석

@Component
@RequiredArgsConstructor
public class PaymentFacade {

    private final QueueService queueService;
    private final PaymentService paymentService;
    private final ConcertService concertService;
    private final UserPointService userPointService;
    private final PushClient pushClient;
    private final DataPlatformClient dataPlatformClient;

    @Transactional
    public PaymentResult.Pay pay(String token, PaymentCommand.Pay command) {

        // 1. 좌석 소유권 배정 (예약됨 > 점유)
        ConcertResult.AssignSeat seatResult = concertService.assignSeat(command.getReservationId());

        // 2. 포인트 잔액 차감
        UserResult.UsePoint pointResult = userPointService.usePoint(new UserCommand.UsePoint(command.getUserId(), command.getPrice()));

        // 3. 대기열 토큰 만료
        queueService.expireToken(token);

        // 4. 결제 정보 저장
        PaymentResult.Pay paymentResult = paymentService.createPayment(command);
        
        // 5. 데이터 플랫폼 전송
        dataPlatformClient.send("결제완료", paymentResult);
        
        // 6. 카카오톡 전송
        pushClient.sendKakaotalk("결제완료", paymentResult);
        
        return paymentResult.toBuilder()
                .userId(command.getUserId())
                .point(pointResult.getPoint())
                .build();
    }
}

Untitled

❗ 문제점


✅ 해결 방안


📌 아키텍처 구조