当前位置:网站首页>ActiveMQ的基础
ActiveMQ的基础
2022-07-03 18:53:00 【兰交余文乐】
一、安装
传送门:ActiveMQ
上面有与JDK对应的版本,否则会报错
ActiveMQ的正确启动需要安装jdk
jdk的安装文档:
linux安装jdk8_最后d轻语的博客-CSDN博客_linux安装jdk
解压命令 :tar -zxvf apache-activemq-5.16.5-bin.tar.gz
进入bin目录 : cd apache-activemq-5.16.5/bin/
启动ActiveMQ : ./activemq start
启动成功界面:
activemq默认端口号为:61616 ,对外访问的端口号为:ip:8161/admin/
账号:admin
密码:admin
无法访问activemq的控制台的解决方案:
传送门:无法访问activemq的8161控制台_WHJwhj552200的博客-CSDN博客_activemq控制台无法访问
注意细节:需要重启activemq
点击Queues可以查看消息队列
二、SpringBoot整合ActiveMQ测试
①导入依赖,下载的那个版本的就引入那个版本的
<!-- activemq 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
②配置文件
server:
port: 8001
spring:
application:
name: activemq
activemq:
broker-url: tcp://xxx.xxx.xxx.xxx:61616
user: admin
password: admin
jms:
pub-sub-domain: false #配置是否为发布订阅模式,默认false为点对点模式
③点对点模式
生成者消息发送:
消费者消息接受:
//注入IOC容器
@Component
public class ActivemqListener {
//设置queue的目的地,与之前配置的destinationName保持一致
@JmsListener(destination = "test-queue")
public void receiveMsg(Message message) throws JMSException {
//因为我们发送的消息为字符串类型,所以这里对类型进行判断筛选
if(message instanceof TextMessage){
//强转为TextMessage
TextMessage textMessage = (TextMessage) message;
System.out.println(textMessage.getText());
}
}
}
最后,启动启动类,即可以点对点的发方式,接收生产者发送过来的消息!
④ 发布订阅
修改配置
生产者
消费者
由于这是发布-订阅模式,所以我们首先要运行消费者,消费者成功启动后,再启动生产者
边栏推荐
- 198. Looting - Dynamic Planning
- 12、 Service management
- 199. Right view of binary tree - breadth search
- PHP determines which constellation it belongs to today
- High concurrency architecture cache
- High concurrency Architecture - separate databases and tables
- [combinatorics] exponential generating function (example of exponential generating function solving multiple set arrangement)
- Record: pymysql is used in pycharm to connect to the database
- 4. Load balancing and dynamic static separation
- 189. Rotation array
猜你喜欢
VLAN experiment
Know what it is, and know why, JS object creation and inheritance [summary and sorting]
[Yu Yue education] theoretical mechanics reference materials of Shanghai Jiaotong University
Administrative division code acquisition
Raft log replication
22.2.14 -- station B login with code -for circular list form - 'no attribute' - 'needs to be in path selenium screenshot deviation -crop clipping error -bytesio(), etc
What does a really excellent CTO look like in my eyes
多媒体NFT聚合平台OKALEIDO即将上线,全新的NFT时代或将来临
MySQL duplicate check
The installation path cannot be selected when installing MySQL 8.0.23
随机推荐
After nohup NPM start &, close the shell window directly, and the process closes accordingly
235. The nearest common ancestor of the binary search tree [LCA template + same search path]
235. 二叉搜索树的最近公共祖先【lca模板 + 找路径相同】
为什么要做特征的归一化/标准化?
Unity2018 to wechat games without pictures
Sustainable service business models
204. Count prime
达梦数据库的物理备份和还原简解
Leetcode: 11. Récipient contenant le plus d'eau [double pointeur + cupidité + enlèvement de la plaque la plus courte]
Torch learning notes (2) -- 11 common operation modes of tensor
Suffix derivation based on query object fields
TypeScript 官网教程
Day-27 database
High concurrency Architecture - separate databases and tables
High concurrency architecture cache
[combinatorics] exponential generating function (example of exponential generating function solving multiple set arrangement)
SSM integration - joint debugging of front and rear protocols (list function, add function, add function status processing, modify function, delete function)
Implementation of cqrs architecture mode under Kratos microservice framework
Opencv learning notes (continuously updated)
Common PostgreSQL commands