-
Notifications
You must be signed in to change notification settings - Fork 16
[김찬호] Sprint12 #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 김찬호
Are you sure you want to change the base?
[김찬호] Sprint12 #174
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements Sprint 12 requirements, adding WebSocket support for real-time messaging and introducing Server-Sent Events (SSE) for push notifications. The implementation includes comprehensive test coverage across unit, integration, and repository layers.
Key Changes:
- Added WebSocket configuration and message broadcasting capabilities
- Implemented SSE infrastructure for real-time notifications
- Created extensive test suite covering services, repositories, controllers, and integration scenarios
Reviewed Changes
Copilot reviewed 195 out of 199 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| SprintMission12/src/test/resources/application-test.yaml | Test configuration for H2 database and JWT settings |
| SprintMission12/src/test/java/com/sprint/mission/discodeit/storage/s3/S3BinaryContentStorageTest.java | Integration tests for S3 storage operations |
| SprintMission12/src/test/java/com/sprint/mission/discodeit/storage/s3/AWSS3Test.java | AWS S3 API integration tests |
| SprintMission12/src/test/java/com/sprint/mission/discodeit/service/basic/* | Unit tests for core service implementations |
| SprintMission12/src/test/java/com/sprint/mission/discodeit/security/* | Security and authentication layer tests |
| SprintMission12/src/test/java/com/sprint/mission/discodeit/repository/* | Repository layer slice tests |
| SprintMission12/src/test/java/com/sprint/mission/discodeit/integration/* | API integration tests |
| SprintMission12/src/test/java/com/sprint/mission/discodeit/event/listener/* | Event listener unit tests |
| SprintMission12/src/test/java/com/sprint/mission/discodeit/controller/* | Controller layer tests |
| SprintMission12/src/main/resources/static/* | Static frontend resources |
| SprintMission12/src/main/java/com/sprint/mission/discodeit/service/SseService.java | SSE service interface definition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @RequiredArgsConstructor | ||
| public class MessageWebSocketController { | ||
|
|
||
| private final SimpMessagingTemplate simpMessagingTemplate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SimpMessagingTemplate 을 Controller 주입하지 않고 Service단에 주입하는게 적절해 보여요.
Controller 쪽은 순수 http 관련 처리만하는게 좋습니다.
| public class WebSocketRequiredEventListener { | ||
| private final SimpMessagingTemplate simpMessagingTemplate; | ||
|
|
||
| public WebSocketRequiredEventListener(SimpMessagingTemplate simpMessagingTemplate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
일관성있게 어노테이션을 이용해서 생성자 주입하시면 좋을것 같아요!
|
sse 이벤트 발생을 EventListener 를 구현해서 발행해보시기 바랍니다. |
요구사항
기본
웹소켓 구현하기
웹소켓 환경 구성
spring-boot-starter-websocket 의존성을 추가하세요.
implementation 'org.springframework.boot:spring-boot-starter-websocket'첨부파일이 포함된 메시지는 기존의 API (POST /api/messages)를 그대로 활용합니다.
메시지 수신
클라이언트는 채널 입장 시 웹소켓으로 /sub/channels.{channelId}.messages 를 구독해 메시지를 수신합니다.
이를 고려해 메시지가 생성되면 해당 엔드포인트로 메시지를 보내는 컴포넌트를 구현하세요.
SSE 구현하기
SSE 환경을 구성하세요.
클라이언트에서 SSE 연결을 위한 엔드포인트를 구현하세요.
GET /api/sse사용자별 SseEmitter 객체를 생성하고 메시지를 전송하는 컴포넌트를 구현하세요.
connect: SseEmitter 객체를 생성합니다.send,broadcast: SseEmitter 객체를 통해 이벤트를 전송합니다.cleanUp: 주기적으로 ping을 보내서 만료된SseEmitter객체를 삭제합니다.ping: 최초 연결 또는 만료 여부를 확인하기 위한 용도로 더미 이벤트를 보냅니다.SseEmitter객체를 메모리에서 저장하는 컴포넌트를 구현하세요.ConcurrentMap: 스레드 세이프한 자료구조를 사용합니다.List<SseEmitter>: 사용자 당 N개의 연결을 허용할 수 있도록 합니다. (예: 다중 탭)이벤트 유실 복원을 위해 SSE 메시지를 저장하는 컴포넌트를 구현하세요.
LastEventId를 전송해 이벤트 유실 복원이 가능하도록 해야 합니다.기존에 클라이언트에서 폴링 방식으로 주기적으로 요청하던 데이터를 SSE를 이용해 서버에서 실시간으로 전달하는 방식으로 리팩토링하세요.
새로운 알림 이벤트 전송
새 알림이 생성되었을 때 클라이언트에 이벤트를 전송하세요.
클라이언트는 이 이벤트를 수신하면 알림 목록에 알림을 추가합니다.
이벤트 명세
배포 아키텍처 구성하기
심화
주요 변경사항
스크린샷
멘토에게