Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,23 @@ public void remindAlarm() {

// 1. 발송 대상 조회 (최대 100개)
List<ScheduleReminder> targets = scheduleReminderRepository.findDueWithScheduleAndUser(
AlarmStatus.ACTIVE, DispatchStatus.PENDING, now, PageRequest.of(0, 100)
AlarmStatus.ACTIVE, DispatchStatus.PENDING, now, PageRequest.of(0, 100)
);

if(targets.isEmpty()) return;
if (targets.isEmpty())
return;

// 2. 선점하기 (발송 상태 변경하기 PENDING -> PROCESSING)
List<Long> targetIds = targets.stream().map(ScheduleReminder::getId).toList();

int lockedCount = scheduleReminderRepository.updateDispatchStatus(targetIds,DispatchStatus.PENDING,DispatchStatus.PROCESSING);
if(lockedCount == 0) return;
int lockedCount = scheduleReminderRepository.updateDispatchStatus(targetIds,
DispatchStatus.PENDING, DispatchStatus.PROCESSING);
if (lockedCount == 0) return;

processNotifications(targetIds);

}
public void processNotifications(List<Long> targetIds) {
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

메서드 가시성 검토 필요

processNotifications() 메서드가 public으로 선언되어 있습니다.

  • 트랜잭션 분리를 위해 self-injection 패턴을 사용할 경우 public이어야 하므로 현재 선언은 적절합니다.
  • 하지만 외부에서 이 메서드를 직접 호출하는 것은 의도되지 않은 동작을 유발할 수 있습니다.
  • 만약 별도 서비스로 분리하는 방안을 선택한다면, 이 메서드는 외부 노출을 제한하는 것이 좋습니다.

권장사항:

  • Self-injection 패턴 사용 시: 현재처럼 public 유지하되, JavaDoc으로 "스케줄러 내부 전용" 명시
  • 별도 서비스 분리 시: 외부 컴포넌트에서 호출 가능하도록 설계하거나, 접근 제한 고려

Based on coding guidelines: 구조 및 설계 - 계층 구조가 올바르게 나뉘어 있는지 확인

🤖 Prompt for AI Agents
In src/main/java/umc/teumteum/server/global/scheduler/RemindAlarmScheduler.java
around line 49, the processNotifications(List<Long> targetIds) method is
declared public but is intended only for scheduler/self-invocation; if you keep
the self-injection / transaction-proxy approach, leave it public and add a
JavaDoc comment above the method clearly stating "scheduler-internal only — do
not call from other components" (and optionally annotate internal use),
otherwise if you refactor this logic into a separate service change the method
visibility to package-private (or protected) and expose a controlled public API
on the new service instead so external callers cannot directly invoke the
scheduler internals.


// 3. 선점 성공한 것들 다시 조회
List<ScheduleReminder> locked = scheduleReminderRepository.findByIdsWithScheduleAndUser(targetIds,DispatchStatus.PROCESSING);
Expand Down
Loading