文章目录
前提
注意Rocket客户端和服务端版本要一致。本部署架构是最小化版本适用于开发测试环境
rocketmq-client
地址:https://search.maven.org/artifact/org.apache.rocketmq/rocketmq-client
rocketmq-spring-boot-starter
注意看内部依赖的rocketmq-client版本
地址:https://search.maven.org/artifact/org.apache.rocketmq/rocketmq-spring-boot-starter
下载
下载地址:https://rocketmq.apache.org/dowloading/releases/
每个版本对应组件所需jdk版本
Version | Client | Broker | NameServer |
---|---|---|---|
4.0.0-incubating | >=1.7 | >=1.8 | >=1.8 |
4.1.0-incubating | >=1.6 | >=1.8 | >=1.8 |
4.2.0 | >=1.6 | >=1.8 | >=1.8 |
4.3.x | >=1.6 | >=1.8 | >=1.8 |
4.4.x | >=1.6 | >=1.8 | >=1.8 |
4.5.x | >=1.6 | >=1.8 | >=1.8 |
4.6.x | >=1.6 | >=1.8 | >=1.8 |
4.7.x | >=1.6 | >=1.8 | >=1.8 |
4.8.x | >=1.6 | >=1.8 | >=1.8 |
4.9.x | >=1.6 | >=1.8 | >=1.8 |
部署
启动NameServer
> nohup sh bin/mqnamesrv &
> tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
注意NameServer默认内存占用4G。可在bin/runserver.sh处查看
启动Broker
> nohup sh bin/mqbroker -n localhost:9876 &
> tail -f ~/logs/rocketmqlogs/broker.log
The broker[%s, xxxx:10911] boot success...
注意Broker默认内存占用8G。可在runbroker.sh处查看
测试收发消息
在发送/接收消息之前,我们需要告诉客户端名称服务器的位置。RocketMQ 提供了多种方法来实现这一点。为简单起见,我们使用环境变量NAMESRV_ADDR
> export NAMESRV_ADDR=localhost:9876
> sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId= ...
> sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_%d Receive New Messages: [MessageExt...
关闭服务器
> sh bin/mqshutdown broker
The mqbroker(36695) is running...
Send shutdown request to mqbroker(36695) OK
> sh bin/mqshutdown namesrv
The mqnamesrv(36664) is running...
Send shutdown request to mqnamesrv(36664) OK