-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] RabbitMqServiceImpl에서 RabbitMqInfo get
- Loading branch information
Showing
1 changed file
with
7 additions
and
16 deletions.
There are no files selected for viewing
23 changes: 7 additions & 16 deletions
23
src/main/java/gdsc/cau/puangbe/photorequest/service/RabbitMqServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |