Skip to content

Commit 7e56cb6

Browse files
committed
hotfix: add redis log
1 parent 809a3d4 commit 7e56cb6

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

src/main/java/com/haru/api/infra/redis/RedisReportConsumer.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,34 @@ public class RedisReportConsumer {
2525
private static final long BATCH_SIZE = 20;
2626

2727
@Scheduled(cron = "0 0/5 * * * *") // 정각부터 5분 마다 실행
28-
public void pollQueueEvery30Minutes() {
28+
public void pollQueueEvery5Minutes() {
2929
long now = Instant.now().getEpochSecond();
30+
log.info("[RedisReportConsumer] pollQueueEvery5Minutes 실행됨 (now = {})", now);
3031

3132
while (true) {
3233
Set<String> dueIds = redisTemplate.opsForZSet()
3334
.rangeByScore(QUEUE_KEY, 0, now, 0, BATCH_SIZE);
3435

35-
if (dueIds == null || dueIds.isEmpty()) break;
36+
if (dueIds == null || dueIds.isEmpty()) {
37+
log.info("[RedisReportConsumer] dueIds 없음 → 반복 종료");
38+
break;
39+
}
40+
41+
log.info("[RedisReportConsumer] 처리할 dueIds: {}", dueIds);
3642

3743
for (String id : dueIds) {
38-
// Worker Queue로 push
39-
redisTemplate.opsForList().leftPush("REPORT_WORKER_QUEUE", id);
40-
// ZSET에서는 제거
41-
redisTemplate.opsForZSet().remove(QUEUE_KEY, id);
44+
try {
45+
// Worker Queue로 push
46+
redisTemplate.opsForList().leftPush("REPORT_WORKER_QUEUE", id);
47+
log.info("[RedisReportConsumer] REPORT_WORKER_QUEUE에 추가됨 → {}", id);
48+
49+
// ZSET에서 제거
50+
redisTemplate.opsForZSet().remove(QUEUE_KEY, id);
51+
log.info("[RedisReportConsumer] ZSET({})에서 제거됨 → {}", QUEUE_KEY, id);
52+
53+
} catch (Exception e) {
54+
log.error("[RedisReportConsumer] id={} 처리 중 에러", id, e);
55+
}
4256
}
4357
}
4458
}
@@ -48,12 +62,12 @@ public void removeFromQueue(Long moodTrackerId) {
4862
try {
4963
Long removed = redisTemplate.opsForZSet().remove(QUEUE_KEY, moodTrackerId.toString());
5064
if (removed != null && removed > 0) {
51-
log.info("즉시 생성 API 호출로 큐에서 제거됨: {}", moodTrackerId);
65+
log.info("[RedisReportConsumer] 즉시 생성 API 큐에서 제거됨: {}", moodTrackerId);
5266
} else {
53-
log.info("큐에 존재하지 않아 제거할 항목 없음: {}", moodTrackerId);
67+
log.info("[RedisReportConsumer] 즉시 생성 API → 큐에 없음: {}", moodTrackerId);
5468
}
5569
} catch (Exception e) {
56-
log.error("큐 제거 실패: {}", moodTrackerId, e);
70+
log.error("[RedisReportConsumer] 즉시 생성 API → 큐 제거 실패: {}", moodTrackerId, e);
5771
}
5872
}
5973
}

0 commit comments

Comments
 (0)