Skip to content
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] chore: 단일 DB로 변경, 인메모리 메시지 브로커 적용 #746

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@Configuration
@EnableRabbit
@Profile("!local")
@Profile("rabbit")
public class RabbitMqConfig {

private static final String CHAT_QUEUE_NAME = "chat.queue";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Profile("local")
@Profile("local | dev | prod")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저희 모든 환경에서 인메모리 메세지로 바꿀 것 같은데
굳이 프로파일 설정안해도 될 것 같아요.
추가하신 특별한 이유가 있는지 궁금합니다.

Copy link
Contributor

@ehtjsv2 ehtjsv2 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제 생각에는 InMemory를 현재 상황에서 local, dev, prod 모두에서 사용중이다 라는 것을 명시적으로 코드에서 보여주고 싶었던 것일 거 같아요. 그렇게 생각하니 좋아보이네요! 나중에 봤을 때 생각의 여지도 적어질 것 같구요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

원래 환경별로 분리하는 것을 염두에 두고 작성한 코드였어서 그대로 두려고 했었는데
지금 상황에서는 생략해도 좋아보이네요

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketLocalConfig implements WebSocketMessageBrokerConfigurer {
public class WebSocketInMemoryConfig implements WebSocketMessageBrokerConfigurer {

private final WebSocketInterceptor webSocketInterceptor;
private final WebSocketErrorHandler webSocketErrorHandler;
private final JwtProvider jwtProvider;

public WebSocketLocalConfig(
public WebSocketInMemoryConfig(
WebSocketInterceptor webSocketInterceptor,
WebSocketErrorHandler webSocketErrorHandler,
JwtProvider jwtProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Profile("!local")
@Profile("rabbit")
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketRabbitMqConfig implements WebSocketMessageBrokerConfigurer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.stereotype.Component;

@Component
@Profile("local")
@Profile("local | dev | prod")
public class InMemoryChatTemplate implements ChatTemplate {

private static final String TOPIC_CHAT_PREFIX = "/exchange/chat.exchange/room.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.stereotype.Component;

@Component
@Profile("!local")
@Profile("rabbit")
public class RabbitChatTemplate implements ChatTemplate {

private final RabbitTemplate rabbitTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy;

@Profile("prod")
@Profile("prod-replication")
@Configuration
public class DataSourceConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import org.springframework.transaction.support.TransactionSynchronizationManager;

@Profile("prod")
@Profile("prod-replication")
public class ReplicationRoutingDataSource extends AbstractRoutingDataSource {

@Override
Expand Down
5 changes: 5 additions & 0 deletions backend/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ spring:
sql:
init:
data-locations:

management:
health:
rabbit:
enabled: false
1 change: 1 addition & 0 deletions backend/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ logging.level.org:
file:
firebase:
path: firebase-friendogly-private-key.json

management:
health:
rabbit:
Expand Down
30 changes: 10 additions & 20 deletions backend/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,25 @@ management:
server:
port: 8081

health:
rabbit:
enabled: false

file:
firebase:
path: firebase-friendogly-private-key.json

spring:
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
sql:
init:
data-locations:

datasource:
writer:
hikari:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: ${WRITER_MYSQL_URL}
read-only: false
username: ${MYSQL_USERNAME}
password: ${MYSQL_PASSWORD}
reader:
hikari:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: ${READER_MYSQL_URL}
read-only: true
username: ${MYSQL_USERNAME}
password: ${MYSQL_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${MYSQL_PROD_RDS_URL}
username: ${MYSQL_PROD_RDS_USERNAME}
password: ${MYSQL_PROD_RDS_PASSWORD}

Comment on lines +44 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저희 mysql rds쓰나요..?

jpa:
hibernate:
ddl-auto: validate
Expand Down
Loading