springboot 整合ActiveMq
2020-12-13 13:44
标签:star des col 队列 sage color queue activemq XML pom.xml 创建消息队列 发送消息 接收消息 springboot 整合ActiveMq 标签:star des col 队列 sage color queue activemq XML 原文地址:https://www.cnblogs.com/yhood/p/11536049.html
//创建队列
@Bean
public Queue queue(){
return new ActiveMQQueue("yhood");
}
@Controller
@RequestMapping("queue")
public class MessageQueueController {
//消息发送者
@Autowired
private JmsTemplate jmsTemplate;
//消息队列(目的地)
@Autowired
private Destination destination;
@RequestMapping("/send/{message}")
@ResponseBody
public String send(@PathVariable(value = "message")String message){
jmsTemplate.convertAndSend(destination,message);
return message;
}
}
@Component
public class Consumer {
@JmsListener(destination = "yhood")
public void reader(String text){
System.out.println("1号接收消息:"+text);
}
}
上一篇:python动态添加属性