From 73b32a3e67bdfd55e0083cab34d43fe7bdbc34de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Tue, 11 Jun 2024 09:19:39 +0900 Subject: [PATCH] [FEAT] stomp heartbeat setting and change exchange type --- .../com/twtw/backend/config/rabbitmq/RabbitMQConfig.java | 4 ++-- .../java/com/twtw/backend/config/socket/StompConfig.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java b/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java index 50176387..d68dc725 100644 --- a/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java @@ -57,8 +57,8 @@ public Queue notificationQueue() { } @Bean - public TopicExchange notificationTopicExchange() { - return new TopicExchange(RabbitMQConstant.NOTIFICATION_EXCHANGE.getName()); + public DirectExchange notificationTopicExchange() { + return new DirectExchange(RabbitMQConstant.NOTIFICATION_EXCHANGE.getName()); } @Bean diff --git a/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java b/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java index b8c03e7c..119d969f 100644 --- a/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java @@ -16,6 +16,7 @@ @EnableWebSocketMessageBroker public class StompConfig implements WebSocketMessageBrokerConfigurer { + private static final int HEART_BEAT_INTERVAL = 10_000; private final RabbitMQProperties rabbitMQProperties; @Override @@ -31,7 +32,9 @@ public void configureMessageBroker(final MessageBrokerRegistry registry) { .setRelayHost(rabbitMQProperties.getHost()) .setRelayPort(61613) .setClientPasscode(rabbitMQProperties.getPassword()) - .setClientLogin(rabbitMQProperties.getUsername()); + .setClientLogin(rabbitMQProperties.getUsername()) + .setSystemHeartbeatSendInterval(HEART_BEAT_INTERVAL) + .setSystemHeartbeatReceiveInterval(HEART_BEAT_INTERVAL); registry.setApplicationDestinationPrefixes("/pub"); }