mq消息服务器03:activemq点对点模式分析,springboot整合activemq

点对点模式分析

也叫队列模式;

mq消息服务器03:activemq点对点模式分析,springboot整合activemq
activeMQ点对点模式.png

activemq消息发送流程:
1.消息生产者把消息发送到activemq消息服务器进行存储;
1)消息生产者发送消息,首先需要在activemq消息服务器中开辟一块空间,存储消息;
2)并且必须给这块空间起一个标识,用来唯一标识这块消息空间;

2.消息消费者必须监听这块空间(此空间监听方法是根据空间标识监听的),监听空间标识必须和消息生产标识一致。

mq消息服务器03:activemq点对点模式分析,springboot整合activemq
点对点示意图.png

消息消费者主动拉取消息;

点对点消息模式的特点:
1.一条消息只能被一个消费者接收。
2.一条消息被消费后就消失了。
3.如果这条消息一致没有被消费,那就一直等待,直到被消费为止。
4.如果有多个消费者同时监听消息空间,遵循先来后到的原则,谁第一个拉取,就给谁消费。

springboot整合activemq

导入activemq

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>

添加热部署
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>

指定activemq服务器url
application.properties
spring.activemq.broker-url=tcp://localhost:61616