Skip to content

[fix] AI 답글 스케줄링을 AFTER_COMMIT 이벤트로 분리하여 댓글 트랜잭션 보호#130

Merged
k3vin7 merged 1 commit into
mainfrom
fix/ai-comment-decouple-reply-scheduling
Apr 1, 2026
Merged

[fix] AI 답글 스케줄링을 AFTER_COMMIT 이벤트로 분리하여 댓글 트랜잭션 보호#130
k3vin7 merged 1 commit into
mainfrom
fix/ai-comment-decouple-reply-scheduling

Conversation

@k3vin7

@k3vin7 k3vin7 commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • AI 댓글에 답글 달 때 scheduleReplyForAiComment()를 직접 호출하던 방식 제거
  • AiReplyScheduleEvent + AiReplyScheduleEventListener(AFTER_COMMIT) 도입으로 트랜잭션 완전 분리
  • 댓글 커밋 성공 후에만 AI 잡 등록 시도, AI 잡 실패가 유저 댓글에 영향 없음
  • scheduleReplyForAiComment()를 ID 기반으로 변경하여 detached entity 문제 방지
  • CommentService에서 AiCommentService 직접 의존 제거

@k3vin7 k3vin7 merged commit 46213e9 into main Apr 1, 2026
1 check failed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the AI reply scheduling logic to use an event-driven architecture, decoupling the CommentService from the AiCommentService by introducing AiReplyScheduleEvent and a corresponding listener. Feedback suggests simplifying the event structure and method signatures by removing the redundant postId, as the post entity can be accessed directly through the aiComment object.


@Transactional
public void scheduleReplyForAiComment(Comment aiComment, Post post) {
public void scheduleReplyForAiComment(Long aiCommentId, Long postId) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

AiReplyScheduleEvent와 이 메서드에서 postId를 별도로 전달받고 있으나, aiComment.getPost()를 통해 이미 해당 엔티티에 접근할 수 있습니다. 이벤트를 발행할 때 aiCommentId만 전달하고 서비스 내부에서 aiComment.getPost()를 활용하면, 이벤트 객체와 메서드 시그니처를 더 간결하게 유지할 수 있습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant