一、各类消息中间件概述:http://www.infoq.com/cn/articles/kafka-vs-rabbitmq
二、ActiveMQ的安装配置:https://blog.csdn.net/u013755987/article/details/61916592
注意:当安装了启动了rabbitMQ时,这时候启动ActiveMQ会发生端口占用
>>>解决方案:关闭rabbitMQ服务,再次启动
三、ActiveMQ springboot demo
(1)代码
1、添加依赖
<dependency><!-- activemq -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
2、配置
spring.activemq.broker-url=tcp://localhost:61616
3、消息体
public class Msg implements MessageCreator {
@Override
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage("测试消息");
}
}
4、发送消息
jmsTemplate.send("my-destination",new Msg());
5、接收消息
@Component
public class Receiver {
@JmsListener(destination = "my-destination")
public void receivedMessage(String message) {
System.out.println("接受到:" + message);
}
}
(2)效果