Created
July 31, 2020 14:38
-
-
Save sophea/337195325a7f422a5891089683cf9151 to your computer and use it in GitHub Desktop.
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
package com.sma.rabbitmq.service; | |
import com.sma.rabbitmq.model.Category; | |
import lombok.extern.slf4j.Slf4j; | |
import org.springframework.amqp.core.AmqpTemplate; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.stereotype.Service; | |
/** | |
* Author: Mak Sophea | |
* Date: 07/31/2020 | |
*/ | |
@Service | |
@Slf4j | |
public class RabbitMQSender { | |
@Autowired | |
private AmqpTemplate rabbitTemplate; | |
@Value("${backend.rabbitmq.exchange}") | |
private String exchange; | |
@Value("${backend.rabbitmq.routingkey}") | |
private String routingkey; | |
public void send(Category category) { | |
rabbitTemplate.convertAndSend(exchange, routingkey, category); | |
log.info("Send msg = {} ", category); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment