Open
Conversation
Firebase Admin SDK 9.7.1 의존성, Spring Retry + AOP 의존성 추가,환경 변수 Base64 방식의 FirebaseConfig 구현, CI/CD에 FIREBASE_ADMIN_KEY 환경 변수 추가 # Conflicts: # build.gradle
Notification, NotificationSetting, UserDevice 엔티티 추가 및 마이그레이션 추가
상태 기반 처리를 위한 쿼리들에 대해 원자성을 보장하기 위해 더티체킹보다는 조건부 쿼리를 이용, Modifying 어노테이션을 이용한 배치 쿼리 추가
FCM 배치 발송 및 Invalid Token 자동 정리, 이벤트 기반 즉시 발송, fcm 호출과의 트랜잭션 분리로 db 커넥션 확보, fcmsent 필드 이용 중복 발송 방지
PENDING/FAILED 재시도 (Exponential Backoff), SENDING 타임아웃 복구 (fcmSent 체크), 조건부 update로 동시성 제어
알림 생성, 읽음, 삭제 API, 알림 설정 관리 API, 토큰 등록/삭제 API, 테스트 알림 발송 API 구현 완료
YAML 기반 메시지 템플릿 관리, 환경별 로딩 전략 (Local: 파일, Dev/Prod: 환경변수 Base64), NotificationMessageFactory로 템플릿 파싱 및 파라미터 치환, CI/CD 스크립트에 환경변수 추가
Friend 이벤트 정의 및 발행, FriendNotificationEventListener로 알림 생성
기존 로직과 새로운 로직 모두 비동기 방식으로 변경, 필요한 쿼리 추가
매일 밤 22시 2일 이상 미답변 사용자에게 푸시 알림 발송, 알림 테이블 저장x, 메모리 기반 중복 방지, fcmclient 직접 호출, 필요한 쿼리 추가
매분 실행, 사용자 설정 시간(분 단위)에 정확히 푸시 발송, 알림 테이블에 저장x, 필요한 쿼리 추가
트랜잭션 제거 후 NotificationTransactionHelper에게 트랜잭션 위임
Collaborator
|
머지 고고~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 요약(Summary)
FCM 기반 푸시 알림 시스템을 구축했습니다. 총 10가지 알림 타입(일일 작성, 미답변, 리포트 완성/제작 가능, 친구 요청/수락)을 이벤트 기반과 스케줄러 기반으로 구현했으며, 알림함 저장, FCM 발송, 재시도 로직, 뱃지 관리까지 전체 알림 인프라를 완성했습니다.
🔗 Related Issue
💬 공유사항
백엔드 구현 설계
1. 알림 발송 아키텍처
이벤트 기반 + 스케줄러 기반 하이브리드 설계
리스너가 즉시 발송
발송
트랜잭션 분리로 성능 최적화
T1: 알림 생성 (PENDING)
↓ AFTER_COMMIT
T2: PENDING → SENDING (낙관적 잠금)
FCM 발송 (트랜잭션 밖) -> 이게 오래 걸려서 이렇게 나눴고, 중복 발송, 재시도 로직을 위해서 상태 기반으로 제어했습니다.
T3: SENDING → SENT/FAILED
2. 조건부 UPDATE 쿼리 사용 이유: 중복 발송 완전 차단
3. 배치 쿼리 사용 이유: 대량 사용자 쿼리를 위해
4. 각 케이스 구현
일일 작성 알림 (매분 실행)
미답변 알림 (매일 22시)
리포트 완성 (이벤트 기반)
리포트 제작 가능 (스케줄러 + 이벤트)
친구 요청/수락 (이벤트 기반)
5. 기존 로직 통합
6. 메시지 템플릿 중앙화
✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.