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

④ 发布订阅
修改配置

生产者

消费者

由于这是发布-订阅模式,所以我们首先要运行消费者,消费者成功启动后,再启动生产者
边栏推荐
- Shell script return value with which output
- 042. (2.11) do it when it's time to do it
- Data analysis is popular on the Internet, and the full version of "Introduction to data science" is free to download
- 235. 二叉搜索树的最近公共祖先【lca模板 + 找路径相同】
- Know what it is, and know why, JS object creation and inheritance [summary and sorting]
- leetcode:11. Container with the most water [double pointer + greed + remove the shortest board]
- Recommend a simple browser tab
- Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
- Administrative division code acquisition
- Understanding of database architecture
猜你喜欢

Mysql45 lecture learning notes (II)
![235. The nearest common ancestor of the binary search tree [LCA template + same search path]](/img/f5/f2d244e7f19e9ddeebf070a1d06dce.png)
235. The nearest common ancestor of the binary search tree [LCA template + same search path]

User identity used by startup script and login script in group policy
![Leetcode: 11. Récipient contenant le plus d'eau [double pointeur + cupidité + enlèvement de la plaque la plus courte]](/img/d4/cbbaec40119be6cb5594899e348261.png)
Leetcode: 11. Récipient contenant le plus d'eau [double pointeur + cupidité + enlèvement de la plaque la plus courte]

Simulation scheduling problem of SystemVerilog (1)

Pytorch introduction to deep learning practice notes 13- advanced chapter of cyclic neural network - Classification

为什么要做特征的归一化/标准化?

Smart wax therapy machine based on STM32 and smart cloud

组策略中开机脚本与登录脚本所使用的用户身份

application
随机推荐
Torch learning notes (2) -- 11 common operation modes of tensor
Scrapy爬虫框架
What is SQL get connection
Pytorch introduction to deep learning practice notes 13- advanced chapter of cyclic neural network - Classification
User identity used by startup script and login script in group policy
Record: writing MySQL commands
Gao Qing, Beijing University of Aeronautics and Astronautics: CIM is a natural quantum computing platform for graph data processing
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Suffix derivation based on query object fields
How to design a high concurrency system
Help change the socket position of PCB part
leetcode:556. 下一个更大元素 III【模拟 + 尽可能少变更】
FBI warning: some people use AI to disguise themselves as others for remote interview
A green plug-in that allows you to stay focused, live and work hard
After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people
The more you talk, the more your stupidity will be exposed.
记录在模拟器中运行flutter时报的错
KINGS
Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)
Zhengda futures news: soaring oil prices may continue to push up global inflation