Files
dognation_BT/src/main/java/com/dog/dognation/scheduler/MatchExpiryScheduler.java
T
sb f6882aef44
CI / build (push) Failing after 16m2s
feat: 매칭 플로우 완성 (진행중·알림·수락 1:1채팅·거절·20분 자동만료)
- 20분 미수락 자동 종료: MatchingRequest.expiresAt + EXPIRED 상태 + 1분 스케줄러
- 신청/수락/거절/만료 시 상대에게 STOMP 알림 (/topic/users/{userId})
- 수락 시 1:1 매칭 채팅방 생성 + 결과(양쪽 강아지 정보) 메시지, /topic/matches/{id}
- 보낸 대기중 조회 GET /api/matches/sent/{dogId} (진행중 표시용)
- 마이그레이션 V7: matching_requests.expires_at, EXPIRED, chat_rooms.match_id

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-11 14:49:39 +09:00

35 lines
1.1 KiB
Java

package com.dog.dognation.scheduler;
import com.dog.dognation.domain.matching.MatchingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* 매칭 신청 20분 자동 종료 스케줄러.
* 1분마다 대기중(PENDING)인데 만료시각이 지난 신청을 EXPIRED 로 처리하고 신청자에게 알린다.
*/
@Component
public class MatchExpiryScheduler {
private static final Logger log = LoggerFactory.getLogger(MatchExpiryScheduler.class);
private final MatchingService matchingService;
public MatchExpiryScheduler(MatchingService matchingService) {
this.matchingService = matchingService;
}
@Scheduled(fixedRate = 60_000)
public void expireOverdueMatches() {
try {
int n = matchingService.expireOverdue();
if (n > 0) {
log.info("[매칭 만료] 20분 미수락 {}건 자동 종료", n);
}
} catch (Exception e) {
log.warn("[매칭 만료] 처리 실패: {}", e.toString());
}
}
}