-
Notifications
You must be signed in to change notification settings - Fork 3
feat : 알림 이벤트 메시지큐 및 캐싱 적용 #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4b11cd9
feat : 알림 이벤트 active mq 적용 및 mongo db 저장 기능 구현
NCookies 06245a9
feat : 알림 발행 트랜잭션 분리
NCookies a18cb5f
feat : 더 이상 사용되지 않는 redis 저장 관련 코드 삭제
NCookies 90a6f64
feat : 알림 데이터 캐싱 및 캐싱 무효화 기능 구현
NCookies 472f0be
feat : 코드 리뷰 피드백 적용
NCookies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,8 @@ src/main/resources/application.properties | |
|
|
||
| # 로컬 개발 설정 | ||
| docker-compose.dev.yml | ||
| /data/ | ||
| /db/ | ||
|
|
||
| # 환경변수 | ||
| .env | ||
| .env | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...fication/event/NotificationReadEvent.java → ...tion/event/NotificationMarkReadEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/org/ezcode/codetest/application/notification/service/NotificationExecutor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package org.ezcode.codetest.application.notification.service; | ||
|
|
||
| import java.util.List; | ||
| import java.util.function.Supplier; | ||
|
|
||
| import org.ezcode.codetest.application.notification.event.NotificationCreateEvent; | ||
| import org.ezcode.codetest.application.notification.port.NotificationEventService; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Propagation; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class NotificationExecutor { | ||
|
|
||
| private final NotificationEventService notificationEventService; | ||
|
|
||
| @Transactional(propagation = Propagation.REQUIRES_NEW) | ||
| public void execute(Supplier<List<NotificationCreateEvent>> notificationsEventSupplier) { | ||
|
|
||
| try { | ||
| List<NotificationCreateEvent> events = notificationsEventSupplier.get(); | ||
|
|
||
| if (events != null && !events.isEmpty()) { | ||
| for (NotificationCreateEvent event : events) { | ||
| notificationEventService.notify(event); | ||
| } | ||
| log.info("알림 이벤트 {}개 발행 성공", events.size()); | ||
| } | ||
| } catch (Exception ex) { | ||
| log.error("알림 이벤트 발행 실패: {}", ex.getMessage(), ex); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
알림 처리 로직의 트랜잭션 경계를 확인해주세요.
새로운
NotificationExecutor기반 람다 패턴이 도입되었는데, 다음 사항들을 검토해주세요:discussionDomainService.getDiscussionById(targetId)를 호출하는데, 이것이 메인 투표 트랜잭션과 별도의 트랜잭션에서 실행되는지 확인이 필요합니다.다음 스크립트로
NotificationExecutor.execute()메서드의 트랜잭션 처리 방식을 확인해주세요:🏁 Script executed:
Length of output: 1545
NotificationExecutor.execute의 트랜잭션 전파가 REQUIRES_NEW임을 확인했습니다.
람다 내부 로직이 메인 투표 트랜잭션과 별도 트랜잭션에서 실행되므로, 아직 커밋되지 않은 투표 반영이
discussionDomainService.getDiscussionById(targetId)호출 시점에 조회되지 않을 수 있습니다.• src/main/java/org/ezcode/codetest/application/community/service/DiscussionVoteService.java:51-63 –
notificationExecutor.execute내부의discussionDomainService.getDiscussionById(targetId)해결 방안 예시:
🤖 Prompt for AI Agents