/*
|
package com.dji.sample.component.rabbitmq.config;
|
|
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.MessageBuilder;
|
import org.springframework.amqp.core.TopicExchange;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
import org.springframework.amqp.support.converter.MessageConverter;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Date;
|
|
@Component
|
public class MqttMsgProxyProducer {
|
@Autowired
|
private RabbitTemplate rabbitTemplate;
|
|
private static final String EXCHANGE_NAME = "mshub.uav";
|
|
@Bean(EXCHANGE_NAME)
|
public TopicExchange createExchange(){
|
return new TopicExchange(EXCHANGE_NAME,true,false);
|
}
|
|
public void publish_test() {
|
// String message = new Date() + "Beijing";
|
Message message = MessageBuilder.withBody("hello javaboy".getBytes())
|
.setExpiration("10000")
|
.build();
|
System.out.println("生产者产生消息=====" + message);
|
rabbitTemplate.convertAndSend(EXCHANGE_NAME,"rabbitmq_queue", message);
|
}
|
|
public void publish(String routingKey, Object content) {
|
rabbitTemplate.convertAndSend(EXCHANGE_NAME,routingKey, content);
|
}
|
|
public void publish(String routingKey, String content) {
|
Message message = MessageBuilder.withBody(content.getBytes())
|
.setExpiration("1000")
|
.build();
|
rabbitTemplate.send(EXCHANGE_NAME,routingKey, message);
|
}
|
|
*/
|
/**
|
* 使用json序列化机制,进行消息转换
|
* @return -
|
*//*
|
|
@Bean
|
public MessageConverter jackson2MessageConverter() {
|
return new Jackson2JsonMessageConverter();
|
}
|
|
}*/
|