Skip to content

Comments

[FEAT] MPS 카프카 이벤트 발행#36

Merged
taemin3 merged 1 commit intomainfrom
SPM-503
Nov 11, 2025
Merged

[FEAT] MPS 카프카 이벤트 발행#36
taemin3 merged 1 commit intomainfrom
SPM-503

Conversation

@taemin3
Copy link
Contributor

@taemin3 taemin3 commented Nov 10, 2025

📝 Summary

  • MPS 카프카 이벤트 발행

🙏 Question & PR point

📬 Reference

Summary by CodeRabbit

  • 새로운 기능

    • MPS 주문 타입에 대한 전문화된 이벤트 처리 추가
    • 주문 상태 변경 완료 시 자동 이벤트 발행 기능
  • 개선사항

    • 이벤트 발행 흐름의 상세 로깅 강화
    • 설정 기반 동적 카프카 리스너 관리 개선

@coderabbitai
Copy link

coderabbitai bot commented Nov 10, 2025

Walkthrough

MPS 주문 타입에 대한 조건부 이벤트 처리 및 로깅을 추가했습니다. PartOrderEventService에서 MPS 관련 이벤트를 별도로 발행하고, FactoryOutboxPublisher에 상세 로깅을 추가하며, PartOrderService에서 상태 전환 시 완료 이벤트를 발행합니다. Kafka 리스너 groupId를 동적 속성으로 변경했습니다.

Changes

Cohort / File(s) 변경 요약
MPS 이벤트 처리 및 로깅
src/main/java/com/sampoom/factory/api/factory/outbox/FactoryOutboxPublisher.java, src/main/java/com/sampoom/factory/api/part/service/PartOrderEventService.java
MPS 이벤트를 PartOrder 경로로 통합 처리하고, 발행 전/후 단계별 로깅 추가(OUTBOX ID, EventType, Topic, Key 등). PartOrderEventService에서 MPS 주문에 대해 MpsCreated, MpsStatusChanged, MpsCompleted, MpsDeleted 이벤트 타입 조건부 발행.
부분 주문 상태 전환 및 이벤트 발행
src/main/java/com/sampoom/factory/api/part/service/PartOrderService.java
getPartOrders 메서드에서 IN_PROGRESS → COMPLETED 상태 전환 감지 시 완료 이벤트 발행 및 엔티티 저장.
Kafka 리스너 설정 동적화
src/main/java/com/sampoom/factory/common/handler/ProjectionEventHandler.java
handlePartForecastEvent의 KafkaListener groupId를 하드코딩된 값(sampoom-factory-test5)에서 Spring 속성 ${spring.kafka.consumer.group-id}로 변경.

Sequence Diagram(s)

sequenceDiagram
    participant OrderService as PartOrderService
    participant EventService as PartOrderEventService
    participant OutboxPublisher as FactoryOutboxPublisher
    participant Kafka as Kafka

    OrderService->>OrderService: getPartOrders()
    OrderService->>OrderService: 상태 변경 감지<br/>(IN_PROGRESS → COMPLETED)
    OrderService->>EventService: recordPartOrderCompleted()
    
    alt MPS 주문 타입
        EventService->>EventService: MpsCompleted 이벤트 생성
        Note over EventService: logging 추가
    else 일반 PartOrder
        EventService->>EventService: PartOrderCompleted 이벤트 생성
    end
    
    EventService->>OutboxPublisher: 이벤트 저장 및 발행
    
    rect rgb(200, 220, 255)
        Note over OutboxPublisher: MPS 이벤트 처리
        OutboxPublisher->>OutboxPublisher: [발행 전] 로깅<br/>(OUTBOX ID, EventType)
        OutboxPublisher->>OutboxPublisher: JSON 변환<br/>(Topic, JsonLength)
        OutboxPublisher->>OutboxPublisher: [전송 전] 로깅<br/>(EventType, Key)
    end
    
    OutboxPublisher->>Kafka: 메시지 발행
    Kafka-->>OutboxPublisher: 성공
    OutboxPublisher->>OutboxPublisher: [발행 후] 로깅<br/>(OUTBOX ID, 상태)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • 주의 필요 영역:
    • PartOrderEventService.java의 조건부 이벤트 타입 분기: 네 가지 이벤트 메서드 모두에서 MPS 로직이 일관되게 적용되었는지 검증 필요
    • PartOrderService.java의 상태 전환 로직: IN_PROGRESS → COMPLETED 완료 이벤트 발행이 중복 이벤트를 생성하지 않는지 확인
    • FactoryOutboxPublisher.java의 로깅 단계: 예외 처리 경로에서 MPS 이벤트 실패 로깅이 완전한지 검토

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • Lee-Jong-Jin
  • Sangyoon98
  • CHOOSLA
  • yangjiseonn

Poem

🐰 MPS 이벤트가 우아하게 흐르고,
로그는 각 단계를 꼼꼼히 기록하네.
상태 전환은 명확히 감지되고,
Kafka로 신호를 보낸다.
토끼의 축복이 함께하길! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 핵심을 정확하게 반영합니다. MPS 카프카 이벤트 발행이라는 제목은 여러 파일에서 MPS 이벤트 타입 처리, 카프카 발행 흐름, 로깅이 추가된 주요 변경사항과 일치합니다.
✨ 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 SPM-503

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4b4839 and a4eed93.

📒 Files selected for processing (4)
  • src/main/java/com/sampoom/factory/api/factory/outbox/FactoryOutboxPublisher.java (1 hunks)
  • src/main/java/com/sampoom/factory/api/part/service/PartOrderEventService.java (2 hunks)
  • src/main/java/com/sampoom/factory/api/part/service/PartOrderService.java (1 hunks)
  • src/main/java/com/sampoom/factory/common/handler/ProjectionEventHandler.java (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-10T02:39:29.568Z
Learnt from: taemin3
Repo: 33-Auto/Sampoom-Management-Backend-Factory PR: 34
File: src/main/java/com/sampoom/factory/api/part/service/PartOrderService.java:668-682
Timestamp: 2025-11-10T02:39:29.568Z
Learning: In the Sampoom Factory project, PartOrder entities always contain only one item per order. The `createPartOrdersSeparately` method in PartOrderService creates individual orders for each item. Therefore, N+1 query concerns in the toResponseDto and toProductionPlanResponseDto methods are not applicable since N is always 1.

Applied to files:

  • src/main/java/com/sampoom/factory/api/part/service/PartOrderEventService.java
  • src/main/java/com/sampoom/factory/api/part/service/PartOrderService.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java-kotlin)

Copy link
Member

@CHOOSLA CHOOSLA left a comment

Choose a reason for hiding this comment

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

카프카 이벤트 확인했습니다! 기대되네요

@taemin3 taemin3 merged commit 3691e86 into main Nov 11, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants