当前位置:网站首页>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());
}
}
}最后,启动启动类,即可以点对点的发方式,接收生产者发送过来的消息!

④ 发布订阅
修改配置

生产者

消费者

由于这是发布-订阅模式,所以我们首先要运行消费者,消费者成功启动后,再启动生产者
边栏推荐
- Change is the eternal theme
- 达梦数据库的物理备份和还原简解
- 我们做了一个智能零售结算平台
- FBI 警告:有人利用 AI 换脸冒充他人身份进行远程面试
- leetcode:11. 盛最多水的容器【双指针 + 贪心 + 去除最短板】
- The installation path cannot be selected when installing MySQL 8.0.23
- Implementation of cqrs architecture mode under Kratos microservice framework
- Record: MySQL changes the time zone
- Day-27 database
- Leetcode: 11. Récipient contenant le plus d'eau [double pointeur + cupidité + enlèvement de la plaque la plus courte]
猜你喜欢
![leetcode:11. Container with the most water [double pointer + greed + remove the shortest board]](/img/d4/cbbaec40119be6cb5594899e348261.png)
leetcode:11. Container with the most water [double pointer + greed + remove the shortest board]

Dart JSON编码器和解码器剖析

Compose LazyColumn 顶部添加控件

NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线

Raft log replication

SSM整合-前后台协议联调(列表功能、添加功能、添加功能状态处理、修改功能、删除功能)

Opencv learning notes (continuously updated)

Raft 日志复制

多媒体NFT聚合平台OKALEIDO即将上线,全新的NFT时代或将来临
随机推荐
Unity webgl optimization
Torch learning notes (7) -- take lenet as an example for dataload operation (detailed explanation + reserve knowledge supplement)
PHP determines which constellation it belongs to today
SSH 远程执行命令简介
FBI 警告:有人利用 AI 换脸冒充他人身份进行远程面试
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
2022.02.11
How to disable the clear button of ie10 insert text box- How can I disable the clear button that IE10 inserts into textboxes?
cipher
After nohup NPM start &, close the shell window directly, and the process closes accordingly
Processing of user input parameters in shell script
Record: install MySQL on ubuntu18.04
Zero length array
How many convolution methods does deep learning have? (including drawings)
Max of PHP FPM_ Some misunderstandings of children
變化是永恒的主題
[combinatorics] exponential generating function (example of exponential generating function solving multiple set arrangement)
flask 生成swagger文档
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Mysql45 lecture learning notes (II)