[IDLE-563] Redis 세션 공유 기반 알림 필터링 및 읽음처리 정상화#269
Conversation
Walkthrough이 PR은 여러 컴포넌트에서 ChatRedisPublisher를 ChatRedisTemplate로 교체하는 작업을 포함합니다. ChatFacadeService와 ChatRedisSubscriber는 새 템플릿을 사용하도록 수정되었으며, ChatRedisTemplate에는 세션 관리(isChatting, delete, setSession) 관련 새로운 메서드들이 추가되었습니다. 또한, 일부 저장소(repository) SQL 쿼리에 필터 조건이 추가되고, 트랜잭션 관리 어노테이션이 개선되었습니다. API와 컨트롤러에서는 단일 채팅방 요약을 반환하는 메서드들이 제거되었으며, WebSocket 핸드셰이크 및 종료 시 Redis 세션 관리 기능이 도입되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant U as 사용자
participant CF as ChatFacadeService
participant CRT as ChatRedisTemplate
U->>CF: sendMessage(message)
CF->>CRT: isChatting(message.receiverId)
alt 수신자가 채팅 중인 경우
CF-->>U: 메시지 발행 생략 (조기 종료)
else 채팅 중이 아닐 경우
CF->>CRT: publish(message)
CF-->>U: 메시지 발행 완료
end
sequenceDiagram
participant D as Disconnect Event
participant WSDL as WebSocketDisconnectListener
participant CRT as ChatRedisTemplate
D->>WSDL: handleDisconnect(event)
WSDL->>WSDL: event에서 userId 추출
alt userId가 존재하는 경우
WSDL->>CRT: delete(userId)
else userId가 없을 경우
WSDL-->>D: 작업 없음
end
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (5)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|



1. 📄 Summary
2. 🤔 고민했던 점
채팅방 내에서 접속한 사용자와 접속하지 않은 사용자를 구분해, 불필요한 알림 푸시를 줄이는 방식을 고민했습니다.
WebSocket 기반 시스템에서 세션 종료나 예상치 못한 끊김 등으로 Redis 정리가 누락되는 상황을 방지할 수 있을지에 대한 고민이 있었습니다.
Redis에 사용자 정보를 저장할 때 어떻게 만료(TTL)를 활용하여 자동 정리를 유도할지, 그리고 이는 실사용자 경험에 영향을 주지 않을지 고려했습니다.
3. 💡 알게된 점, 궁금한 점
WebSocket 연결 시점과 종료 시점에 Redis를 통해 세션을 관리하면, 실시간 사용자 상태 추적이 가능한 것을 알게되었고, STOMP기반이기 때문에 handshake와 connection이 닫기는 이벤트에 따라 Redis에 id값을 관리하도록 하였습니다.
Redis에 TTL(Time-To-Live)을 설정해두면, 예기치 못한 예외 상황에도 리소스가 자동으로 정리되는 이점이 있음을 알게되었습니다.
이에따라, 사용자가 정상적으로 접속 종료하지 않더라도 세션 정보가 과도하게 쌓이지 않고 일정 시간 뒤 정리되도록 하였습니다.
Summary by CodeRabbit