[BE-09] alerting worker·scheduler (비동기 처리·발송 브리지·self-check)
작업 내용 (설계 의도)
변경 사항
alerting 이벤트를 비동기 처리하고 notification 발송으로 브리지하는 presentation 컴포넌트를 작성한다. 근거 TDD: §시스템 역할 경계·§Sequence·ADR-004(교차는 이벤트).
presentation/alerting/worker/AlertProcessingEventWorker.kt—@Async @TransactionalEventListener(AFTER_COMMIT)가AlertProcessingRequestedEvent소비 →ProcessAlertUseCase.execute(alertId). (webhook 스레드와 분리해 Grafana 타임아웃 회피.)presentation/alerting/worker/AlertDeliveryEventWorker.kt—@Async @TransactionalEventListener(AFTER_COMMIT)가AlertDeliveryReadyEvent소비 → notificationSendNotificationUseCase.execute(channel=DISCORD, userId=recipient, payload={title,body,source,severity,env}). 교차 도메인은 이벤트→presentation→application(notification) 경로(도메인 import 금지).presentation/alerting/scheduler/AlertSelfCheckScheduler.kt—@Scheduled(cron = "0 0 * * * *")→SendSelfCheckUseCase(McpAnomalyScheduler 선례).- recipient userId는 config(
alerting.discord.recipient-user-id)에서 주입받아 Command에 전달(worker는 값만 전달).
의존
- BE-07 (ProcessAlertUseCase, SendSelfCheckUseCase)
- BE-01 (AlertProcessingRequestedEvent, AlertDeliveryReadyEvent)
- (기존) notification SendNotificationUseCase
다이어그램
처리 흐름
sequenceDiagram participant PW as ProcessingEventWorker participant PU as ProcessAlertUseCase participant DW as DeliveryEventWorker participant SN as SendNotificationUseCase PW->>PU: process(alertId) [AFTER_COMMIT] DW->>SN: send(DISCORD, recipient, payload) [AFTER_COMMIT]
테스트 케이스
- AlertProcessingRequestedEvent 커밋 후 ProcessAlertUseCase가 호출된다(AFTER_COMMIT).
- AlertDeliveryReadyEvent 소비 시 SendNotificationUseCase가 channel=DISCORD로 호출된다.
- 발송 payload에 title/body/source/severity/env가 모두 포함된다(태그 누락 0).
- self-check 스케줄러가 cron 실행 시 SendSelfCheckUseCase를 호출한다.
- ProcessAlertUseCase가 예외를 던져도 worker가 로깅하고 다른 이벤트 처리를 막지 않는다.