Skip to content

Commit

Permalink
[refactor] RabbitMqServiceImpl에서 RabbitMqInfo get
Browse files Browse the repository at this point in the history
  • Loading branch information
RumosZin committed Aug 13, 2024
1 parent 1bec202 commit 8aca07b
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
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
@RequiredArgsConstructor
@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());
}
}

0 comments on commit 8aca07b

Please sign in to comment.