-
Notifications
You must be signed in to change notification settings - Fork 3
채팅서버 카프카 연결 #164
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
채팅서버 카프카 연결 #164
Conversation
mirlee0304
left a comment
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.
것참 신기하군요 카프카란.. 수고하셨습니당!
ki-met-hoon
left a comment
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.
고생하셨습니다!!👍
| //스프링 인메모리 메시지 브로커 사용 | ||
| config.enableSimpleBroker("/subscribe"); //구독 prefix | ||
| config.setApplicationDestinationPrefixes("/publish"); //발행 prefix | ||
| config.setApplicationDestinationPrefixes("/publish"); // STOMP 메시지 발행 prefix |
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.
yml 파일 설정 추가 또는 @value를 쓰는 것도 방법이라고 생각합니다!
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.
해당 부분은 대댓글 진행하며 prefix 추후 리팩토링 시 반영하겠습니다!
| @Entity | ||
| @Getter | ||
| @Setter | ||
| public class Files { |
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.
Entity가 하나라 BaseEntity를 생성 안하신걸까요?
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.
맞습니다! 근데 서버 내 이미 BaseTimeEntity를 구현했어서 수정하겠습니다! 꼼꼼리뷰..최고
| public ChatMessageResponse createMessage(Long userId, String content){ | ||
| User user = userRepository.findByUserId(userId); | ||
| return new ChatMessageResponse(user.getNickname(),content); | ||
| public List<MessageResponse> createMessage(ChatMessageRequest request) { |
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.
함수의 분리를 고민해보셔도 좋을 것 같아요!
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.
해당 부분은 추후 리팩토링 진행하겠습니다!
| String stockDataJson = objectMapper.writeValueAsString(stockUpdate); | ||
|
|
||
| messagingTemplateBroker.convertAndSend("/subscribe/stock", stockDataJson); | ||
| messagingTemplate.convertAndSend("/subscribe/stock", stockDataJson); |
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.
String으로 변경할 필요가 있을까요? stockUpdate 객체를 보내도 JSON 변환이 안되나요?
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내 convertAndSend 메서드 체인에서 doConvert 메서드가 호출되며, 이 과정에서 MessageConverter를 사용해 payload를 Message 객체로 변환되기도 한다네요!
하지만 저희같은 경우엔 ChatMessageToKafka내에 List로 되어있는데 MessageResponse가 인터페이스다보니 Jackson이 처리를 잘 못하는 경우가 발생합니다. 그래서 명시적으로 json 객체로 변환하는 것이 안전할 것 같습니다
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.
명시적으로 Json 형태의 문자열로 만든다는 의미신거죠?
Spring에서 자체적으로 객체를 Json 데이터로 처리하는 것보다 Json 형태의 문자열로 변경하는게 더 안전할 것 같긴하네요!!
|
|
||
| @KafkaListener( | ||
| topics = "${topic.chat}", | ||
| topics = "jootalkpia.chat.prd.message", |
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.
여기는 yml 설정을 안가져온 이유가 있을까요?
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.
컨슈머 내 2개의 kafkaListener를 사용하니 인식이 잘 안되는 문제가 발생했습니다 ㅠㅠ 우선 변수로 수정 후 배포시에도 문제가 발생하면 수정해야겠어요
Pull request
Related issue
Resolve #81
Motivation and context
Solution
kafka를 통한 data의 최종 흐름
인터페이스를 통해 메세지에 맞는 응답 구조를 구현했습니다.
How has this been tested
kafka를 통한 소켓 실시간 통신

첨부파일 형식 별 알맞은 응답

Types of changes
Checklist