ActiveMQ 是Apache出品,最流行的,能力强劲的开源消息总线。ActiveMQ 是一个完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现。多种语言和协议编写客户端。语言: Java,C,C++,C#,Ruby,Perl,Python,PHP。应用协议: OpenWire,Stomp REST,WS Notification,XMPP,AMQP。引用自ActiveMQ

activemq结构:

P/M结构

spring boot +activeMQ(一)

P/T结构:

spring boot +activeMQ(一)

spring boot整合ActiveMQ:

一、引入ActiveMQ spring boot依赖:

   <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-activemq -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-activemq</artifactId>
    <version>2.0.3.RELEASE</version>

</dependency>

二、application.properties配置activeMQ:

#spring boot activeMQ配置
#服务中心地址
spring.activemq.broker-url=tcp://127.0.0.1:61616
#服务中心用户名
spring.activemq.password=admin
#服务中心密码

spring.activemq.user=admin

注:这里我开始端口号使用的是登陆的8161,测试了半天一直报错,链接失败。。这里登陆和服务端口不一样

这里只写一个消费者和生产者

生产者:

spring boot +activeMQ(一)

实现消息接口具体发送消息:

spring boot +activeMQ(一)

创建消费者:

spring boot +activeMQ(一)

测试:

spring boot +activeMQ(一)

结果:

spring boot +activeMQ(一)

注:在启动类中使用注解提供JMS支持:@EnableJms

发布者/订阅者模式,区别在于:

①创建new ActiveMQTopic(String topic)

②配置监听

spring boot +activeMQ(一)

相关文章: