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 all 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 @@ -4,24 +4,22 @@
import com.happy.friendogly.auth.service.jwt.JwtProvider;
import java.util.List;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Profile("local")
@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") // RabbitMQ가 필요한 상황에서는 해당 프로파일명을 변경해주세요.
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketRabbitMqConfig implements WebSocketMessageBrokerConfigurer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.happy.friendogly.chatsocket.template;

import org.springframework.context.annotation.Profile;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

@Component
@Profile("local")
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") // RabbitMQ가 필요한 상황에서는 해당 프로파일명을 변경해주세요.
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") // DB 이중화하는 경우 프로파일명을 변경해주세요.
@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") // DB 이중화하는 경우 프로파일명을 변경해주세요.
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