消息发送
/**
* @author wsyjlly
* @create 2019.07.18 - 1:13
**/
@Component
public class RabbitmqSchedule {
@Autowired
RabbitTemplate rabbitTemplate;
Logger logger = LoggerFactory.getLogger(getClass());
@Scheduled(cron = "0-30/6 * * * * ?")
public void topic(){
String message = "topic-task";
int i = 0;
logger.info("\033[32;4m"+message+"\033[0m");
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic1.news",message + 1);//topic1
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic1.salary",message + 2);//topic1
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic2.news",message + 3);//topic2
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic2.item",message + 4);//topic2
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic2.sth.topic1",message + 5);//topic2&topic1
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic1.sth.topic2",message + 6);//topic2&topic1
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic3",message + 7);//topic3
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic3.news",message + 8);//topic3
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic1.topic3",message + 9); //topic1&topic3
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic2.topic3",message + 10);//topic2&topic3
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic3.topic1",message + 11);//topic3&topic1
rabbitTemplate.convertAndSend(RabbitTopicConfig.TOPIC_NAME,
"topic2.topic3.topic1",message + 12);//topic1&topic2&topic3
}
}