Conversation
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
Pull Request Overview
Implements asynchronous notification processing to improve system performance by preventing blocking operations during notification handling.
- Added Spring async configuration with custom thread pool executor
- Converted notification services to use asynchronous processing with @async annotation
- Refactored event listeners to use @eventlistener instead of @TransactionalEventListener for better async handling
- Extracted restock targeting logic into a separate service class for better separation of concerns
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| SpringAsyncConfig.java | Configures async processing with custom thread pool settings |
| ReportNotificationService.java | Adds @async annotation to enable asynchronous report notification processing |
| ReportListenerEvent.java | Changes from @TransactionalEventListener to @eventlistener for async compatibility |
| RestockDeleteTargetingService.java | New service class extracted from event listener to handle restock targeting logic |
| ReStockRepository.java | Adds join fetch optimization for user data retrieval |
| RentalListenerEvent.java | Refactors to use extracted service and adds @async for asynchronous processing |
|
Walkthrough이번 변경사항에서는 Restock(재입고) 알림 대상자 선정 및 알림 로직을 별도의 서비스( Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–25 minutes
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 7
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/main/java/com/TwoSeaU/BaData/domain/rental/event/RentalListenerEvent.java(2 hunks)src/main/java/com/TwoSeaU/BaData/domain/rental/repository/ReStockRepository.java(1 hunks)src/main/java/com/TwoSeaU/BaData/domain/rental/service/RestockDeleteTargetingService.java(1 hunks)src/main/java/com/TwoSeaU/BaData/domain/trade/event/ReportListenerEvent.java(2 hunks)src/main/java/com/TwoSeaU/BaData/domain/trade/service/ReportNotificationService.java(2 hunks)src/main/java/com/TwoSeaU/BaData/global/config/SpringAsyncConfig.java(1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: dionisos198
PR: Ureca-Final-Project-Team2/be_badata#366
File: src/main/java/com/TwoSeaU/BaData/domain/rental/event/RestockEvent.java:17-23
Timestamp: 2025-08-03T14:38:14.569Z
Learning: RestockEvent.from() 팩토리 메서드에서 null 검증은 불필요하다. 파라미터가 null일 경우 이전 서비스 코드에서 이미 오류가 발생하므로 중복 검증을 피한다.
Learnt from: dionisos198
PR: Ureca-Final-Project-Team2/be_badata#366
File: src/main/java/com/TwoSeaU/BaData/domain/rental/event/RentalListenerEvent.java:89-90
Timestamp: 2025-08-03T14:37:51.472Z
Learning: 재입고 알림 시스템에서는 예약이 취소된 기간(rentalStart, rentalEnd)을 기준으로 가용 수량을 확인한다. 이는 취소된 예약 기간을 통해 재입고 알림이 트리거되는 이벤트 기반 비즈니스 로직에 부합한다.
Learnt from: dionisos198
PR: Ureca-Final-Project-Team2/be_badata#102
File: src/main/java/com/TwoSeaU/BaData/domain/rental/service/RestockService.java:48-48
Timestamp: 2025-07-14T07:27:02.452Z
Learning: 재입고 알림(ReStock) 비즈니스 로직: 재입고 알림은 해당 기간에 예약이 불가능할 때만 신청할 수 있다. 예약 가능한 수량이 충분하다면 재입고 알림을 신청할 수 없고 예외가 발생한다.
📚 Learning: review-reservation 간 1:1 관계에서 외래키 제약조건은 데이터 무결성을 보장하지만, jpa 지연 로딩으로 인한 lazyinitializationexception 방...
Learnt from: dionisos198
PR: Ureca-Final-Project-Team2/be_badata#144
File: src/main/java/com/TwoSeaU/BaData/domain/rental/dto/response/ShowReviewResponse.java:34-34
Timestamp: 2025-07-18T05:16:04.655Z
Learning: Review-Reservation 간 1:1 관계에서 외래키 제약조건은 데이터 무결성을 보장하지만, JPA 지연 로딩으로 인한 LazyInitializationException 방지를 위해서는 연관된 User 엔티티도 함께 fetch해야 한다. NPE 체크보다는 쿼리 개선이 더 나은 해결책이다.
Applied to files:
src/main/java/com/TwoSeaU/BaData/domain/rental/repository/ReStockRepository.java
📚 Learning: in the be_badata codebase, event classes (like reportemailevent, reportfcmevent) and response dtos c...
Learnt from: dionisos198
PR: Ureca-Final-Project-Team2/be_badata#357
File: src/main/java/com/TwoSeaU/BaData/domain/trade/event/ReportFcmEvent.java:12-14
Timestamp: 2025-08-02T19:06:31.945Z
Learning: In the be_badata codebase, Event classes (like ReportEmailEvent, ReportFcmEvent) and Response DTOs consistently use non-final private fields (e.g., `private String contents`, `private List<String> tokens`). Request DTOs have mixed patterns with some using final fields. The field name "contents" is consistently used across report-related events rather than "content".
Applied to files:
src/main/java/com/TwoSeaU/BaData/domain/trade/event/ReportListenerEvent.javasrc/main/java/com/TwoSeaU/BaData/domain/rental/event/RentalListenerEvent.java
📚 Learning: 재입고 알림 시스템에서는 예약이 취소된 기간(rentalstart, rentalend)을 기준으로 가용 수량을 확인한다. 이는 취소된 예약 기간을 통해 재입고 알림이 트리거되는 이...
Learnt from: dionisos198
PR: Ureca-Final-Project-Team2/be_badata#366
File: src/main/java/com/TwoSeaU/BaData/domain/rental/event/RentalListenerEvent.java:89-90
Timestamp: 2025-08-03T14:37:51.472Z
Learning: 재입고 알림 시스템에서는 예약이 취소된 기간(rentalStart, rentalEnd)을 기준으로 가용 수량을 확인한다. 이는 취소된 예약 기간을 통해 재입고 알림이 트리거되는 이벤트 기반 비즈니스 로직에 부합한다.
Applied to files:
src/main/java/com/TwoSeaU/BaData/domain/rental/event/RentalListenerEvent.java
📚 Learning: restockevent.from() 팩토리 메서드에서 null 검증은 불필요하다. 파라미터가 null일 경우 이전 서비스 코드에서 이미 오류가 발생하므로 중복 검증을 피한다....
Learnt from: dionisos198
PR: Ureca-Final-Project-Team2/be_badata#366
File: src/main/java/com/TwoSeaU/BaData/domain/rental/event/RestockEvent.java:17-23
Timestamp: 2025-08-03T14:38:14.569Z
Learning: RestockEvent.from() 팩토리 메서드에서 null 검증은 불필요하다. 파라미터가 null일 경우 이전 서비스 코드에서 이미 오류가 발생하므로 중복 검증을 피한다.
Applied to files:
src/main/java/com/TwoSeaU/BaData/domain/rental/event/RentalListenerEvent.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: build-test
🔇 Additional comments (5)
src/main/java/com/TwoSeaU/BaData/domain/trade/service/ReportNotificationService.java (1)
34-36: @async와 @transactional 조합 검토 필요
sendReportNotification메서드에
@Transactional(readOnly = true)와@Async("threadPoolTaskExecutor")를 함께 적용하면
비동기 스레드에서 트랜잭션 컨텍스트가 정상적으로 전파되지 않을 수 있습니다.
또한 이 메서드는 주로 이벤트 발행 위주이므로 읽기 전용 트랜잭션이 꼭 필요한지 재검토가 필요합니다.
- 파일:
src/main/java/com/TwoSeaU/BaData/domain/trade/service/ReportNotificationService.java- 대상 메서드:
public void sendReportNotification(final Report report)전체 코드베이스에서 동일한 패턴이 다른 곳에 없는지, 혹은 이 조합이 의도한 대로 동작하는지 확인 부탁드립니다.
src/main/java/com/TwoSeaU/BaData/domain/rental/repository/ReStockRepository.java (1)
13-19: 성능 최적화가 잘 적용되었습니다.
join fetch r.user u추가로 N+1 쿼리 문제를 방지하고 LazyInitializationException을 예방했습니다. 새로운RestockDeleteTargetingService에서 사용자 데이터에 접근할 때 효율적인 쿼리가 가능합니다.src/main/java/com/TwoSeaU/BaData/domain/rental/event/RentalListenerEvent.java (2)
35-35: 서비스 분리가 잘 이루어졌습니다.
RestockDeleteTargetingService로 책임을 분리하여 코드의 응집도와 재사용성이 향상되었습니다. 복잡한 타겟팅 로직이 별도 서비스로 캡슐화되어 테스트와 유지보수가 용이해졌습니다.
37-38: 알림 발송 순서 변경 검토 필요
sendFcmToken 호출이 sendEmail 호출보다 먼저 실행되도록 변경된 것으로 보입니다. 사용자 경험 관점에서 의도된 변경인지 확인해주세요.
- 파일: src/main/java/com/TwoSeaU/BaData/domain/rental/event/RentalListenerEvent.java
- 라인: 37–38
rg 검색 결과, 코드베이스 내에서 이전 발송 순서를 참조할 수 있는 다른 구현 예제가 발견되지 않았습니다. 변경 사항이 의도된 것인지 다시 한번 검토 부탁드립니다.
src/main/java/com/TwoSeaU/BaData/domain/rental/service/RestockDeleteTargetingService.java (1)
29-30: 트랜잭션 전파 설정 정상 확인됨
RentalListenerEvent에서@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void handleRestockDeleteEvent(RestockDeleteEvent restockEvent) { List<User> sendTargetUser = restockDeleteTargetingService.getSendTargetUser(...); … }와 같이 부모 트랜잭션(예약 취소)이 커밋된 후에
getSendTargetUser가 호출되므로,REQUIRES_NEW프로퍼게이션이 커밋된 변경사항을 정상적으로 조회할 수 있습니다.
- 검증 위치:
src/main/java/com/TwoSeaU/BaData/domain/rental/event/RentalListenerEvent.java –handleRestockDeleteEvent따라서 추가 수정이나 검증은 필요 없으며, 해당 리뷰 코멘트는 무시해주세요.
Likely an incorrect or invalid review comment.
#️⃣연관된 이슈
🚀 작업 내용
🔍 리뷰 요청 사항
알림 비동기 처리