| | |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Value("${spring.rabbitmq.enable}") |
| | | private Boolean flag; |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | public void saveLogToMq(String topic_exchange, String routingKey, DeviceMessage message) { |
| | | if (rabbitTemplate.isRunning()) { |
| | | if (flag && rabbitTemplate.isRunning()) { |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(topic_exchange, routingKey, message); |
| | | } else { |