[DABOM-508] SSE 로직 개선 작업#31
Conversation
- UsageRecordKafkaConsumer 삭제 (USAGE_REALTIME 토픽 리스너) - UsageRealtimeBroadcastKafkaConfig 삭제 (브로드캐스트 전용 컨테이너 팩토리) - application.yml에서 spring.kafka.broadcast 설정 제거 - 사용량 데이터는 PollingService의 DB Polling으로 전환 예정
- PollingService를 Redis polling에서 DB 직접 polling으로 전환 - FamilyRepository에서 totalQuotaBytes, usedBytes 조회 - CustomerQuotaRepository 신규 생성, familyId 기준 멤버별 monthlyUsedBytes 조회 - 하드코딩 제거 (totalLimitBytes=20000, customerId=4L 등) - SsePublisher에서 pushTotalUsageBytes, pushMemberUsageBytes 및 CAS 맵 제거 - SsePublisher는 pushNotificationEvent만 유지
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! 이 PR은 사용량 데이터의 실시간 SSE 전송 구조를 개선하는 것을 목표로 합니다. 기존의 Kafka 컨슈머와 Redis 폴링이 동시에 동작하며 발생하던 충돌 문제를 해결하고, 1초 간격으로 DB를 직접 폴링하는 단일 경로로 시스템을 통합하여 데이터 일관성과 효율성을 높였습니다. 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. 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. Footnotes
|
- familyRepository.findAllById()로 활성 family 일괄 조회하여 N+1 방지 - customerQuotaRepository.findByFamilyIdIn()으로 변경된 family의 멤버 쿼터 일괄 조회 - findById().orElse(null) 패턴 제거, Map 기반 조회로 전환 - 변경된 familyId만 필터링 후 멤버 쿼터 조회하여 불필요한 쿼리 최소화
- 사용량 변경 시 usage-updated, usage-updated-by-member 이벤트 전송 검증 - 사용량 미변경 시 이벤트 미전송 검증 - Family 미존재 시 이벤트 미전송 검증
- 이벤트명 "usage-updated", "usage-updated-by-member"를 상수로 추출 - putIfAbsent + put 중복 호출을 get + put 단일 호출로 간결화
- @scheduled(fixedDelay = 1000) 매직넘버를 POLLING_DELAY_MS 상수로 추출 - DB 조회 메서드에 @transactional(readOnly = true) 선언하여 일관된 읽기 보장 - spotlessApply 포매팅 적용
- FamilyCacheRepository 삭제 (DB Polling 전환으로 사용처 없음) - FamilyCacheDto 삭제 (FamilyCacheRepository 전용) - RedisKeyGenerator 삭제 (FamilyCacheRepository 전용) - RedisConfig 삭제 (두 RedisTemplate bean 모두 FamilyCacheRepository 전용)
- SsePublisher에서 미사용 @slf4j 어노테이션 제거 - CustomerQuotaRepository에서 미사용 findByFamilyId() 메서드 제거
SonarQube Quality Summary (Community)❌ Quality Gate FAILED Branch: Issues
Measures
🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-api-notification Generated automatically by GitHub Actions. |
- 모든 인자가 구체 값인 verify()에서 eq() 래핑 제거 - any()와 혼용되는 곳은 Mockito 규칙상 eq() 유지
SonarQube Quality Summary (Community)✅ Quality Gate PASSED Branch: Issues
Measures
🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-api-notification Generated automatically by GitHub Actions. |
🍀 이슈 & 티켓 넘버
🎯 목적
사용량 데이터의 SSE 실시간 전송 구조를 개선합니다. Kafka 컨슈머와 Redis polling이 동시에 동작하며 충돌하던 문제를 해소하고, 1초 간격 DB 직접 polling 단일 경로로 통일합니다.
📝 변경 사항
USAGE_REALTIME컨슈머 및 브로드캐스트 전용 설정 삭제PollingService를 Redis polling에서 DB 직접 polling으로 전환 (Family, CustomerQuota 테이블 조회)totalLimitBytes=20000,customerId=4L등)SsePublisher에서 미사용 usage push 메서드 및 CAS 맵 제거,pushNotificationEvent()만 유지CustomerQuotaRepository신규 생성📂 변경 범위
🖥️ 주요 코드 설명
PollingService DB Polling 전환
💬 리뷰어에게
USAGE_REALTIME토픽은 더 이상 이 서비스에서 소비하지 않습니다. 토픽 자체의 삭제 여부는 별도 논의가 필요합니다.usage-updated,usage-updated-by-member)과 페이로드 구조(RealtimeTotalUsageResponse,RealtimeUsageByMemberResponse)는 기존과 동일하여 프론트엔드 변경은 불필요합니다.📋 체크리스트
기본
./gradlew build가 정상적으로 통과하는가?./gradlew spotlessApply checkstyleMain)코드 품질
Controller → Service → Repository → Entity)@Transactional은 Service에만 선언했는가?테스트
📌 참고 사항
application.yml에서spring.kafka.broadcast설정이 제거되었으므로 환경변수KAFKA_BROADCAST_GROUP_PREFIX정리 가능FamilyCacheRepository는 이번 변경으로PollingService에서 더 이상 사용하지 않으며, 다른 사용처가 없으면 후속 정리 대상