Skip to content

Feat: 이벤트 기반 알림 파이프라인 도입 - #25

Merged
ssarisong merged 10 commits into
mainfrom
feat/18-notification-event
Sep 11, 2026
Merged

Feat: 이벤트 기반 알림 파이프라인 도입#25
ssarisong merged 10 commits into
mainfrom
feat/18-notification-event

Conversation

@KIMB0B

@KIMB0B KIMB0B commented Sep 11, 2026

Copy link
Copy Markdown
Member

📌 변경 내용

  • 이벤트 기반 알림 파이프라인 구현: 도메인 이벤트 → Outbox(같은 트랜잭션 기록) → Relay 폴링 → Redis StreamConsumer Group → 알림 DB 생성(1:N 팬아웃) → Pub/Sub + WebSocket 실시간 push
  • 데이터 모델 추가: Notification(내용) / NotificationRecipient(수신자별 읽음 상태) / OutboxEvent(발행 대기함), works 다중 담당자용 work_assignees
  • REST API: 내 알림 목록 / 안읽음 개수 / 읽음·전체읽음 처리 (/notifications 이하)
  • 실시간: /notifications/ws WebSocket + 홈 헤더 종 아이콘(안읽음 배지 / 드롭다운 / 새 알림 즉시 반영 / 클릭 시 대상 페이지 이동)
  • 이벤트 9종 프로듀서 연동: notice_created/updated, work_assigned/work_status_changed, project 초대/수락/거절/강퇴/리더위임
  • 작업 다중 담당자 기능(검색·칩 선택 UI) 및 담당자에게 작업 배정/상태변경 알림
  • access token 만료 시 refresh token으로 자동 재발급(auth.js, 401 인터셉트 후 재시도)

🎯 변경 이유

  • 공지·작업·프로젝트에서 발생하는 변화를 사용자가 놓치지 않도록 실시간 + 영속(안읽음 목록) 알림이 필요했습니다.
  • 알림 전달 로직을 도메인 로직과 분리하고, 저장과 발행의 원자성을 보장하기 위해 Transactional Outbox + 메시지 큐(Redis Streams) 구조를 도입했습니다. (Dual-Write 문제 회피, at-least-once 보장)
  • 새로운 이벤트는 NotificationEvents에 메서드 추가 + 도메인 서비스에서 호출만 하면 되어 확장 비용이 낮습니다.

🔗 관련 이슈

🧪 테스트 방법

  • 로컬에서 직접 테스트
  • 테스트 코드 추가/수정
  • 수동 테스트 (아래 설명)

테스트 상세

사전: docker compose up -d (db/redis/api), 로그에 "Outbox relay 시작됨" / "Notification 컨슈머 시작됨" 확인

[공지 알림]
1. 홈에서 로그인 → 헤더 🔔 표시
2. 프로젝트에 공지 등록
3. 프로젝트 멤버 계정에 실시간 알림 도착, 안읽음 배지 +1, 클릭 시 공지 상세로 이동

[작업 담당자 알림]
1. 프로젝트 상세 → "새 할 일" → 담당자 검색·칩으로 2명 지정 후 저장
2. 지정된 담당자에게 "새 작업이 배정되었어요" 실시간 알림 도착
3. 작업 상태 변경 시 담당자에게 상태 변경 알림 도착

[읽음 처리]
1. GET /notifications, GET /notifications/count/unread 확인
2. 알림 클릭(읽음) → 안읽음 수 감소, "모두 읽음" 동작 확인

[파이프라인 상태]
- redis-cli XPENDING notifications:stream notification-workers → 0 (처리 완료)

✅ 체크리스트

  • 기존 기능에 영향 없음
  • 에러/엣지 케이스 고려 (빈 수신자 스킵, at-least-once, 트랜잭션 롤백)
  • 관련 문서 업데이트 (필요 시)

🔭 남은 확장 포인트 (의도적 보류)

  • 자기 자신(행위자) 알림 제외
  • 멱등성(중복 알림 방지) / 재시도 상한·DLQ / XAUTOCLAIM(컨슈머 pending 복구) / 스트림 MAXLEN

@KIMB0B
KIMB0B requested a review from ssarisong September 11, 2026 06:12
@KIMB0B KIMB0B self-assigned this Sep 11, 2026

@ssarisong ssarisong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

확인 완료했습니다.

@ssarisong
ssarisong merged commit 73b9881 into main Sep 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 이벤트 기반 알림 파이프라인 도입 (Outbox + Redis Streams)

2 participants