1. 启动 NameServer
nohup sh bin/mqnamesrv &
执行结果示例:
The Name Server boot success. serializeType=JSON
2. 启动 Broker
nohup sh bin/mqbroker -n localhost:9876 &
执行结果示例:
The broker[192.168.0.1:10911] boot success. serializeType=JSON and name server is localhost:9876
3. 查看 NameServer 配置信息
sh bin/mqadmin clusterList -n localhost:9876
执行结果示例:
#Cluster Name #Broker Name #Addr DefaultCluster broker-a 192.168.0.1:10911 DefaultCluster broker-b 192.168.0.2:10911
4. 创建 Topic
sh bin/mqadmin updateTopic -c DefaultCluster -n localhost:9876 -t TopicTest
执行结果示例:
create topic to 192.168.0.1:10911 success.
5. 发送消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
执行结果示例:
SendResult [sendStatus=SEND_OK, msgId=...
6. 消费消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
执行结果示例:
ConsumeMessageThread_1 Receive New Messages: ...
7. 查看消息堆积情况
sh bin/mqadmin queryMsgById -n localhost:9876 -i XXXXXXXX
执行结果示例:
Message ID: XXXXXXXX Topic: TopicTest Queue ID: 0 StoreSize: 1024 BornTimestamp: 1646755200000 StoreTimestamp: 1646755201000
结论
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏