-
Notifications
You must be signed in to change notification settings - Fork 0
[채팅] redis pub/sub을 활용한 채팅 #93
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
509764b
feat: websocket 라이브러리 추가(#76)
acceptor-gyu f390f42
feat: socket config 추가(#87)
acceptor-gyu 7e7cb36
feat: redis pub/sub 메시지 구현(#87)
acceptor-gyu dab2985
feat: 채팅 기능 구현(#87)
acceptor-gyu b221a06
feat: 메시지 목록 조회(#87)
acceptor-gyu 373bea3
feat: 채널 토픽 로그 추가(#87)
acceptor-gyu 7ee962f
fix: 오타 및 어노테이션 수정(#87)
acceptor-gyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
15 changes: 15 additions & 0 deletions
15
be/src/main/java/yeonba/be/chatting/dto/request/ChatPublishRequest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package yeonba.be.chatting.dto.request; | ||
|
||
import java.io.Serializable; | ||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ChatPublishRequest implements Serializable { | ||
|
||
private long roomId; | ||
private long userId; | ||
private String userName; | ||
private String content; | ||
private LocalDateTime sentAt; | ||
} |
15 changes: 15 additions & 0 deletions
15
be/src/main/java/yeonba/be/chatting/dto/request/ChatSubscribeResponse.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package yeonba.be.chatting.dto.request; | ||
|
||
import java.io.Serializable; | ||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ChatSubscribeResponse implements Serializable { | ||
|
||
private long roomId; | ||
private long userId; | ||
private String userName; | ||
private String content; | ||
private LocalDateTime sentAt; | ||
} |
17 changes: 0 additions & 17 deletions
17
be/src/main/java/yeonba/be/chatting/dto/request/ChattingSendMessageRequest.java
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
be/src/main/java/yeonba/be/chatting/dto/response/ChatMessageResponse.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package yeonba.be.chatting.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ChatMessageResponse { | ||
|
||
private long userId; | ||
private String userName; | ||
private String content; | ||
private LocalDateTime sentAt; | ||
} |
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
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
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
4 changes: 4 additions & 0 deletions
4
be/src/main/java/yeonba/be/chatting/repository/chatmessage/ChatMessageRepository.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
package yeonba.be.chatting.repository.chatmessage; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
import yeonba.be.chatting.entity.ChatMessage; | ||
import yeonba.be.chatting.entity.ChatRoom; | ||
|
||
@Repository | ||
public interface ChatMessageRepository extends JpaRepository<ChatMessage, Long> { | ||
|
||
ChatMessage findFirstByChatRoomIdOrderBySentAtDesc(long chatRoomId); | ||
|
||
int countByChatRoomIdAndReadIsFalse(long chatRoomId); | ||
|
||
List<ChatMessage> findAllByChatRoomOrderBySentAtDesc(ChatRoom chatRoom); | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
be/src/main/java/yeonba/be/chatting/service/RedisChattingPublisher.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package yeonba.be.chatting.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.listener.ChannelTopic; | ||
import org.springframework.stereotype.Service; | ||
import yeonba.be.chatting.dto.request.ChatPublishRequest; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class RedisChattingPublisher { | ||
|
||
private final RedisTemplate<String, Object> redisTemplate; | ||
|
||
public void publish(ChannelTopic topic, ChatPublishRequest request) { | ||
|
||
redisTemplate.convertAndSend(topic.getTopic(), request); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
ChatService
의getChatMessages()
와acceptRequestedChat()
의 경우 명시적인 트랜잭션 선언이 안 되어있는데 그 이유가 궁금합니다.