Skip to content

[나은비] sprint11 - #245

Open
nano-mm wants to merge 51 commits into
codeit-bootcamp-spring:mainfrom
nano-mm:나은비-sprint11

Hidden character warning

The head ref may contain hidden characters: "\ub098\uc740\ube44-sprint11"
Open

nano-mm wants to merge 51 commits into
codeit-bootcamp-spring:mainfrom
nano-mm:나은비-sprint11

Conversation

@nano-mm

@nano-mm nano-mm commented Jun 14, 2026

Copy link
Copy Markdown

요구사항

기본

Spring Event - 파일 업로드 로직 분리하기

  • BinaryContentCreatedEvent 정의
  • ApplicationEventPublisher를 활용하여 BinaryContentStorage 직접 호출 제거
  • UserService.create/update, MessageService.create, BinaryContentService.create에서 이벤트 발행
  • Transaction Commit 이후 바이너리 데이터를 저장하는 Event Listener 구현
  • BinaryContent 상태(status) 필드 추가 (PROCESSING, SUCCESS, FAIL)
  • BinaryContent 상태 변경 메서드 구현
  • 바이너리 데이터 저장 성공 시 SUCCESS 상태 반영
  • 바이너리 데이터 저장 실패 시 FAIL 상태 반영

Spring Event - 알림 기능 추가하기

  • MessageCreatedEvent 정의 및 메시지 생성 시 이벤트 발행
  • ReadStatus.notificationEnabled 필드 추가
  • PRIVATE 채널은 알림 활성화(true) 기본값 적용
  • PUBLIC 채널은 알림 비활성화(false) 기본값 적용
  • ReadStatusUpdateRequest에 알림 설정 기능 추가
  • RoleUpdatedEvent 정의 및 권한 변경 시 이벤트 발행
  • Notification API 구현
  • 알림 조회 API 구현 (GET /api/notifications)
  • 알림 확인 API 구현 (DELETE /api/notifications/{notificationId})
  • NotificationRequiredEventListener 구현
  • MessageCreatedEvent 수신 시 알림 생성
  • RoleUpdatedEvent 수신 시 알림 생성

비동기 적용하기

  • AsyncConfig 구현
  • @EnableAsync 적용
  • TaskExecutor Bean 등록
  • MDC Request ID 전달 TaskDecorator 구현
  • SecurityContext 전달 TaskDecorator 구현
  • Event Listener 비동기 처리(@async 적용)
  • 메시지 생성 API 실행 시간 측정(@timed)
  • Actuator 설정 추가
  • 동기/비동기 성능 비교 수행

비동기 실패 처리하기

  • Spring Retry 환경 구성
  • @EnableRetry 적용
  • 바이너리 저장 로직에 @retryable 적용
  • 재시도 정책 설정
  • @recover 적용
  • S3 업로드 실패 알림 이벤트 구현
  • 관리자 알림 생성

캐시 적용하기

  • Caffeine Cache 환경 구성
  • 사용자별 채널 목록 조회 캐시 적용
  • 사용자별 알림 목록 조회 캐시 적용
  • 사용자 목록 조회 캐시 적용
  • 데이터 변경 시 CacheEvict 적용
  • 캐시 적용 전후 SQL 실행 비교
  • Actuator 캐시 통계 확인
  • recordStats 설정 적용

심화

Spring Kafka 도입하기

  • Docker Compose 기반 Kafka 환경 구성
  • Spring Kafka 의존성 추가
  • Kafka Producer 설정
  • Kafka Consumer 설정
  • KafkaProduceRequiredEventListener 구현
  • Spring Event → Kafka 이벤트 변환 및 발행
  • Kafka Console을 통한 이벤트 발행 확인
  • NotificationRequiredTopicListener 구현
  • Kafka Listener 기반 알림 생성
  • 기존 EventListener 기반 알림 로직 제거

Redis Cache 도입하기

  • Docker Compose 기반 Redis 환경 구성
  • Spring Data Redis 설정
  • Redis Cache 설정
  • Redis 직렬화 설정 적용
  • Redis CacheManager 적용
  • DataGrip을 통한 Redis 캐시 데이터 확인

주요 변경사항

  • Spring Event 기반으로 파일 업로드 로직을 분리하여 트랜잭션 점유 시간을 최소화했습니다.
  • BinaryContent 상태(PROCESSING, SUCCESS, FAIL)를 추가하여 업로드 상태를 추적할 수 있도록 개선했습니다.
  • 메시지 생성 및 권한 변경 시 알림 이벤트를 발행하도록 리팩토링했습니다.
  • Notification API를 구현하여 사용자별 알림 조회 및 확인 기능을 추가했습니다.
  • AsyncConfig와 TaskDecorator를 적용하여 비동기 환경에서도 SecurityContext와 MDC(Request ID)를 유지하도록 구현했습니다.
  • Spring Retry를 활용하여 S3 업로드 실패 시 자동 재시도 및 Recover 로직을 적용했습니다.
  • Caffeine Cache를 적용하여 사용자, 채널, 알림 조회 성능을 개선했습니다.
  • Kafka를 도입하여 이벤트 기반 알림 시스템을 서버 외부로 확장할 수 있도록 구성했습니다.
  • Redis Cache를 적용하여 멀티 인스턴스 환경에서도 공유 가능한 전역 캐시를 구축했습니다.
  • Actuator를 활용하여 비동기 처리 성능 및 캐시 통계 정보를 확인할 수 있도록 구성했습니다.

스크린샷

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

apple and others added 30 commits January 25, 2026 17:36
feat: 나은비 스프린트 미션 2 1차·2차 구현
feat: Sprint Mission 3 - 기본 요구사항, 심화 요구사항 구현
@eedys1234
eedys1234 self-requested a review June 15, 2026 12:18
this.contentType = contentType;
}

public void markSuccess() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

메서드 시그니처를 통해 의미를 부여한점 👍👍👍

this.user = user;
this.channel = channel;
this.lastReadAt = lastReadAt;
this.notificationEnabled = notificationEnabled;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this.notificationEnabled = Channel.PRIVATE == channel;

이건 어떠실까요?

@NotNull(message = "새로운 마지막 읽은 시간은 필수입니다")
@PastOrPresent(message = "마지막 읽은 시간은 현재 또는 과거 시간이어야 합니다")
Instant newLastReadAt,
Boolean notificationEnabled

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

별건 아니지만 요구사항에는 newNotificationEnabled로 필드명이 되어있는 것 같습니다.

org.springframework.security: TRACE

cache:
caffeine:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cache-names 이 누락된것같습니다.

@eedys1234

Copy link
Copy Markdown
Collaborator

은비님! 병합하려는 브랜치 변경 부탁드려요!

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.

4 participants