From 8aca07b2feee3bc5b7f225cc5fe486de2de6d7c7 Mon Sep 17 00:00:00 2001 From: rumos Date: Tue, 13 Aug 2024 23:28:39 +0900 Subject: [PATCH] =?UTF-8?q?[refactor]=20RabbitMqServiceImpl=EC=97=90?= =?UTF-8?q?=EC=84=9C=20RabbitMqInfo=20get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/RabbitMqServiceImpl.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/gdsc/cau/puangbe/photorequest/service/RabbitMqServiceImpl.java b/src/main/java/gdsc/cau/puangbe/photorequest/service/RabbitMqServiceImpl.java index e435fe5..148dd1d 100644 --- a/src/main/java/gdsc/cau/puangbe/photorequest/service/RabbitMqServiceImpl.java +++ b/src/main/java/gdsc/cau/puangbe/photorequest/service/RabbitMqServiceImpl.java @@ -1,10 +1,9 @@ package gdsc.cau.puangbe.photorequest.service; -import gdsc.cau.puangbe.photorequest.dto.ImageInfo; +import gdsc.cau.puangbe.common.config.RabbitMq.RabbitMqInfo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Service @@ -12,26 +11,18 @@ @Slf4j public class RabbitMqServiceImpl implements RabbitMqService{ - @Value("${rabbitmq.queue.name}") - private String queueName; - - @Value("${rabbitmq.exchange.name}") - private String exchangeName; - - @Value("${rabbitmq.routing.key}") - private String routingKey; - private final RabbitTemplate rabbitTemplate; + private final RabbitMqInfo rabbitMqInfo; /** * 1. Queue 로 메세지를 발행 * 2. Producer 역할 -> Direct Exchange (메시지의 routing key와 정확히 일치하는 binding된 Queue로 routing) **/ public void sendMessage(String message) { - this.rabbitTemplate.convertAndSend(exchangeName, routingKey, message); - log.info("**Message Send**: {}",message); - log.info("messagge queue: {}", queueName); - log.info("messagge exchange: {}", exchangeName); - log.info("messagge routingKey: {}", routingKey); + this.rabbitTemplate.convertAndSend(rabbitMqInfo.getExchangeName(), rabbitMqInfo.getRoutingKey(), message); + log.info("**Message Send**: {}", message); + log.info("messagge queue: {}", rabbitMqInfo.getQueueName()); + log.info("messagge exchange: {}", rabbitMqInfo.getExchangeName()); + log.info("messagge routingKey: {}", rabbitMqInfo.getRoutingKey()); } }