-
Notifications
You must be signed in to change notification settings - Fork 3
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
[BE] fix: 외부 메시지 큐(RabbitMQ) 도입, 분산 환경 채팅 안 되던 버그 수정 #630
Conversation
Test Results221 tests 221 ✅ 18s ⏱️ Results for commit 6f456ce. ♻️ This comment has been updated with latest results. |
rabbitmq: | ||
host: ${RABBITMQ_HOST} | ||
username: ${RABBITMQ_USERNAME} | ||
password: ${RABBITMQ_PASSWORD} | ||
port: 5672 | ||
stomp-port: 61613 |
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.
dev에서는 로컬 서버와 default port를 사용합니다.
management: | ||
health: | ||
rabbit: | ||
enabled: false |
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.
local 환경에서는 RabbitMQ를 쓰지 않고 in-memory 메시지큐를 사용하는데
프로파일 분리를 해도 자꾸 RabbitMQ 헬스체크를 시도해서 해당 설정 껐습니다.
rabbitmq: | ||
host: ${RABBITMQ_PROD_HOST} | ||
username: ${RABBITMQ_PROD_USERNAME} | ||
password: ${RABBITMQ_PROD_PASSWORD} | ||
port: 3100 # initial connection port: use 3100 instead of 5672 | ||
stomp-port: 9100 # STOMP port: use 9100 instead of 61613 |
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.
메시지 큐 전용 서버에서는 기본 포트인 5672, 61613을 사용하지 않고
인바운드 규칙에 열려 있는 3100, 9100을 사용합니다.
이걸 사용하려면 /etc/rabbitmq
에서 포트를 바꿔주는 설정을 먼저 해야 합니다. (prod와 같은 subnet에서 연결 테스트 완료)
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.
좋네요. 노션에 정리해놓은 게 있어서, 이슈에 올려 놓았습니다!
#616 (comment)
@Bean | ||
public Jackson2JsonMessageConverter jackson2JsonMessageConverter() { | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
objectMapper.registerModule(javaTimeModule()); | ||
return new Jackson2JsonMessageConverter(objectMapper); | ||
} | ||
|
||
@Bean | ||
public Module javaTimeModule() { | ||
return new JavaTimeModule() | ||
.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(TIME_FORMAT)) | ||
.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(TIME_FORMAT)); | ||
} |
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.
기본 설정만으로는 LocalDateTime을 직렬화하지 못해서 작성함
(기본 설정으로는 배열로 직렬화하도록 되어 있음)
@Component | ||
public interface ChatTemplate { | ||
|
||
void convertAndSend(Long chatRoomId, Object payload); | ||
} |
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.
interface 빈으로 등록하고 계십니당
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.
반영 완
// template.convertAndSend( | ||
// "/topic/invite/" + request.receiverMemberId(), | ||
// new InviteToChatRoomResponse(request.chatRoomId()) | ||
// ); |
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.
일대일 채팅방 만들때 다시 로직 살릴예정!
import org.springframework.context.annotation.Profile; | ||
|
||
@Configuration | ||
@EnableRabbit |
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.
나이스요!
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.
설명 듣고 다시 리뷰하겠습니당~
rabbitmq: | ||
host: ${RABBITMQ_PROD_HOST} | ||
username: ${RABBITMQ_PROD_USERNAME} | ||
password: ${RABBITMQ_PROD_PASSWORD} | ||
port: 3100 # initial connection port: use 3100 instead of 5672 | ||
stomp-port: 9100 # STOMP port: use 9100 instead of 61613 |
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.
토미가 추가로 만들어주신 보안 그룹을 설정 해주신거죵?
이 외에도 코드에 드러나지 않는 변경 사항이 많을 것 같은데, 이런 내용은 추적하기 힘드니 따로 기록한 뒤에 공유해주시면 좋을 것 같습니다!
# Conflicts: # .github/workflows/backend-cd-workflow-dev.yml # .github/workflows/backend-cd-workflow-prod.yml # backend/src/main/java/com/happy/friendogly/chat/controller/ChatSocketController.java
이슈
개발 사항
리뷰 요청 사항 (없으면 삭제해 주세요)
전달 사항 (없으면 삭제해 주세요)