Conversation
설명
변경사항
예상 코드 리뷰 노력🎯 1 (Trivial) | ⏱️ ~3 분 제안 리뷰어
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
nowait-domain/domain-redis/src/main/java/com/nowait/domaincoreredis/rank/listener/CookingCompleteListener.java (2)
18-22: @EnableAsync가 누락되어@Async애너테이션이 무시됨 - 긴급 수정 필요현재 프로젝트에
@EnableAsync애너테이션이 존재하지 않습니다. 이로 인해 18번 라인의@Async는 완전히 무시되며,onCookingComplete()메서드는 동기적으로 실행됩니다.이는 다음 문제들을 야기합니다:
- 비동기로 의도된 코드가 실제로는 동기 실행되어 트랜잭션 완료 시점을 지연
AFTER_COMMIT이벤트 리스너가 트랜잭션 완료를 차단할 수 있음- 데이터베이스 쓰기 작업이 이벤트 리스너 내에서 동기 실행됨
필수 조치:
- 애플리케이션 메인 클래스에
@EnableAsync추가MenuCounterService호출 전용TaskExecutor생성 및@Async("menuCounterExecutor")명시- 비동기 메서드에 예외 처리 및 로깅 추가
🔧 필수 변경사항
ApiUserApplication.java / ApiAdminApplication.java에 추가:
`@EnableAsync` `@SpringBootApplication` public class ApiUserApplication { // ... }AsyncConfig.java에 추가:
`@Bean`(name = "menuCounterExecutor") public Executor menuCounterExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(3); executor.setMaxPoolSize(5); executor.setQueueCapacity(50); executor.setThreadNamePrefix("MenuCounter-"); executor.initialize(); return executor; }CookingCompleteListener.java 변경:
- `@Async` + `@Async`("menuCounterExecutor") `@TransactionalEventListener`( classes = CookingCompleteEvent.class, phase = TransactionPhase.AFTER_COMMIT ) - public void onCookingComplete(CookingCompleteEvent event) { - Long storeId = event.getStoreId(); - for (CookingCompleteEvent.Item item : event.getItems()) { - menuCounterService.incrementMenuCounter( - item.getMenuId(), - storeId, - item.getQuantity() - ); - } - } + public void onCookingComplete(CookingCompleteEvent event) { + try { + Long storeId = event.getStoreId(); + for (CookingCompleteEvent.Item item : event.getItems()) { + menuCounterService.incrementMenuCounter( + item.getMenuId(), + storeId, + item.getQuantity() + ); + } + } catch (Exception e) { + // Log error - async void methods swallow exceptions silently + throw e; + } + }
23-31: @async 메서드의 예외 처리 누락으로 인한 조용한 장애 가능성
@Async+void리턴 메서드의 예외는 호출부로 전파되지 않습니다. 현재 코드베이스에는@EnableAsync가 전역으로 활성화되지 않았으며,AsyncUncaughtExceptionHandler설정도 없어 예외가 로깅 없이 묻힐 수 있습니다. 최소한 로깅 처리가 필수적입니다.📋 예외 로깅 추가 예시
+import lombok.extern.slf4j.Slf4j; `@Component` `@RequiredArgsConstructor` +@Slf4j public class CookingCompleteListener { private final MenuCounterService menuCounterService; `@Async` `@TransactionalEventListener`( classes = CookingCompleteEvent.class, phase = TransactionPhase.AFTER_COMMIT ) public void onCookingComplete(CookingCompleteEvent event) { - Long storeId = event.getStoreId(); - for (CookingCompleteEvent.Item item : event.getItems()) { - menuCounterService.incrementMenuCounter( - item.getMenuId(), - storeId, - item.getQuantity() - ); - } + try { + Long storeId = event.getStoreId(); + for (CookingCompleteEvent.Item item : event.getItems()) { + menuCounterService.incrementMenuCounter( + item.getMenuId(), + storeId, + item.getQuantity() + ); + } + } catch (Exception ex) { + log.error("CookingCompleteEvent 처리 실패: storeId={}", event.getStoreId(), ex); + throw ex; + } }
작업 요약
Issue Link
#346
문제점 및 어려움
해결 방안
Reference
Summary by CodeRabbit
릴리스 노트
✏️ Tip: You can customize this high-level summary in your review settings.