package me.zhengjie.config.rabbitmq.test; import me.zhengjie.config.rabbitmq.cuisine.CuisineConsumer; import me.zhengjie.config.rabbitmq.cuisine.CuisineProduce; import me.zhengjie.config.rabbitmq.order.OrderProduce; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @Component public class SendTemplate { @Autowired @Qualifier(CuisineConsumer.TEMPLATE_CON) private RabbitTemplate rabbitTemplate; @Autowired @Qualifier(OrderProduce.TEMPLATE_ORDER) private RabbitTemplate rabbitTemplate1; public void sendMessage(Object message){ rabbitTemplate.convertAndSend(CuisineConsumer.NAME, CuisineConsumer.NAME, message.toString()); System.out.println("世贸发送消息----消息发送到rabbitmq"); System.out.println(message); } public void sendOrederMessage(Object message){ rabbitTemplate1.convertAndSend(OrderProduce.NAME_ORDER, OrderProduce.NAME_ORDER, message.toString()); System.out.println("雄伟发送消息----消息发送到rabbitmq"); } }