[DABOM-447] usage-events 정산 단순화 및 알림 outbox 도입#55
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
전반적으로 매우 훌륭한 리팩토링입니다. usage-events 처리 로직을 직접 정산 방식으로 단순화하고, 알림 발행에 Outbox 패턴을 도입하여 시스템의 안정성과 데이터 정합성을 크게 향상시켰습니다. 특히 복잡했던 Lua 스크립트를 구조화하고, 실패 시 복구 흐름을 명확하게 설계한 점이 인상적입니다. 코드 품질 향상을 위해 중복 로직 제거 및 매직넘버 상수화 등 몇 가지 개선점에 대한 코멘트를 남겼으니 확인 부탁드립니다.
SonarQube Quality Summary (Community)❌ Quality Gate FAILED Branch: Issues
Measures
🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-processor-usage&branch=feat/DABOM-447 Generated automatically by GitHub Actions. |
|
👋 PR 리마인드 알림입니다 이 PR이 몇 시간 동안 업데이트되지 않았어요.
바쁘실 수 있다는 점 이해합니다 🙏 |
|
/gemini review |
SonarQube Quality Summary (Community)❌ Quality Gate FAILED Branch: Issues
Measures
🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-processor-usage&branch=feat/DABOM-447 Generated automatically by GitHub Actions. |
There was a problem hiding this comment.
Code Review
이번 PR은 usage-events 처리 로직을 대폭 개선하여 정산 구조를 단순화하고, 알림 발행을 위해 Outbox 패턴을 도입한 점이 인상적입니다. 전반적으로 코드의 안정성과 유지보수성이 크게 향상되었습니다. 특히 아래와 같은 점들이 돋보입니다.
usage-persistKafka 단계를 제거하고usage-events소비 시점에 DB에 직접 정산하도록 변경하여 흐름을 단순화했습니다.- 알림 발행에 Outbox 패턴과 비동기 발행, 배치 재시도 로직을 도입하여 메시지 유실 가능성을 크게 줄였습니다.
- Lua 스크립트를 구조화하고 상태 문자열 해석 로직을 Java 코드로 중앙화하여 가독성과 유지보수성을 높였습니다.
- 캐시와 DB를 함께 사용하는
family-customer관계 검증 로직을 초입에 추가하여 잘못된 데이터의 후속 처리를 미리 방지했습니다.
코드 리뷰에서는 스타일 가이드에 따라 RuntimeException을 직접 사용하는 부분을 ApplicationException으로 변경하도록 두 가지 제안을 드렸습니다. 이 부분을 수정하면 코드의 일관성과 예외 처리 정책 준수 수준이 더욱 높아질 것입니다. 훌륭한 리팩터링입니다.
SonarQube Quality Summary (Community)✅ Quality Gate PASSED Branch: Issues
Measures
🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-processor-usage&branch=feat/DABOM-447 Generated automatically by GitHub Actions. |
🍀 이슈 & 티켓 넘버
🎯 목적
usage-events처리 경로에서 Kafka 사용으로 인해 생기는 멱등성, 정합성, 실패 복구 문제를 서비스 내부에서 더 명확하게 통제하기 위해 구조를 정리했습니다.기존에는
usage-persist를 통한 간접 정산 구조와 notification 발행 책임 분리가 모호했고, 실패 시 어느 지점부터 어떻게 복구되는지 설명하기 어려웠습니다. 이번 변경에서는 DB 정산을usage-events소비 서비스가 직접 수행하도록 단순화하고, notification은 Outbox + 즉시 비동기 발행 + 배치 복구 구조로 재정리했습니다.📝 변경 사항
usage-persistproducer/consumer 경로를 제거하고usage-events처리 중 DB 직접 정산으로 변경usage_event_outbox엔티티/리포지토리/서비스 추가PUBLISH_PENDING복구 구조로 변경familyId-customerId관계를 Redis membership cache + DB fallback으로 초입 검증하도록 추가family:{familyId}:customer:{customerId}:alert:...형식으로 정리NORMAL등 알림 비대상 이벤트는 payload 생성 없이SKIPPED로 종료되도록 수정📂 변경 범위
🖥️ 주요 코드 설명
💬 리뷰어에게
📋 체크리스트
기본
./gradlew build가 정상적으로 통과하는가?./gradlew spotlessApply checkstyleMain)코드 품질
Controller → Service → Repository → Entity)@Transactional은 Service에만 선언했는가?테스트
📌 참고 사항