Skip to content

Commit 1e0e19a

Browse files
committed
feature: DLQ 이벤트 모니터링 인터페이스 및 기본 구현체 추가
- `MonitoringService` 인터페이스 및 `DummyMonitoringAdapter` 구현체 추가 - DLQ 저장소에서 이벤트 저장 성공 시 메트릭 증가 로직 추가 - 이벤트 저장 실패 시 치명적 알림 로직 적용 (모니터링 서비스 활용)
1 parent bf4fd3c commit 1e0e19a

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

apps/commerce-api/src/main/java/com/loopers/application/event/FailedEventStore.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.core.JsonProcessingException;
44
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import com.loopers.application.monitoring.port.MonitoringService;
56
import com.loopers.domain.event.DomainEvent;
67
import com.loopers.domain.event.FailedEvent;
78
import com.loopers.infrastructure.event.FailedEventRepository;
@@ -16,6 +17,7 @@ public class FailedEventStore implements FailedEventScheduler {
1617

1718
private final FailedEventRepository failedEventRepository;
1819
private final ObjectMapper objectMapper;
20+
private final MonitoringService monitoringService;
1921

2022
@Transactional
2123
@Override
@@ -38,7 +40,11 @@ public <T extends DomainEvent> void scheduleRetry(T event, String reason) {
3840

3941
try {
4042
failedEventRepository.save(failedEvent);
43+
monitoringService.incrementMetric("dlq.event_saved_total", "type:" + failedEvent.getEventType());
44+
4145
} catch (Exception e) {
46+
monitoringService.sendCriticalAlert(
47+
"CRITICAL: DLQ 저장소 장애. 이벤트 유실 위험 발생! 사유: " + e.getMessage(), e);
4248
}
4349
}
4450
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.loopers.application.monitoring.port;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.stereotype.Component;
5+
6+
@Slf4j
7+
@Component
8+
public class DummyMonitoringAdapter implements MonitoringService {
9+
@Override
10+
public void incrementMetric(String name, String tag) {
11+
log.info("[METRIC_DUMMY] Increment | Name: {} | Tag: {}", name, tag);
12+
}
13+
14+
@Override
15+
public void sendCriticalAlert(String message, Throwable t) {
16+
log.error("[ALERT_DUMMY] CRITICAL ALERT: {}", message, t);
17+
}
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.loopers.application.monitoring.port;
2+
3+
public interface MonitoringService {
4+
5+
void incrementMetric(String name, String tag);
6+
7+
void sendCriticalAlert(String message, Throwable t);
8+
}

0 commit comments

Comments
 (0)