本文实践环境说明:Windows 10 专业版,JDK 1.8.0_65。
下载
http://rocketmq.apache.org/dowloading/releases/
解压 rocketmq-all-4.1.0-incubating-bin-release.zip
到 <rocketmq-installed-dir>
启动服务
启动 NameServer
1 | %ROCKETMQ_HOME%/bin/mqnamesrv -n 127.0.0.1:9876 >E:\logs\mqnamesrv.log |
The Name Server boot success. serializeType=JSON
启动 Broker
1 | %ROCKETMQ_HOME%/bin/mqbroker -n 127.0.0.1:9876 >E:\mqbroker.log |
运行客户端
配置环境变量: NAMESRV_ADDR
-> 127.0.0.1:9876
发送消息
1 | %ROCKETMQ_HOME%/bin/tools org.apache.rocketmq.example.quickstart.Producer |
SendResult [sendStatus=SEND_OK, msgId=0A00BF859C787EA987AC2DCBCA8A0354, offsetMsgId=0A00BF8500002A9F00000000000256A2, messageQueue=MessageQueue [topic=TopicTest, brokerName=Dawn, queueId=0], queueOffset=213]
SendResult [sendStatus=SEND_OK, msgId=0A00BF859C787EA987AC2DCBCA8C0355, offsetMsgId=0A00BF8500002A9F0000000000025756, messageQueue=MessageQueue [topic=TopicTest, brokerName=Dawn, queueId=1], queueOffset=213]
SendResult [sendStatus=SEND_OK, ……
接收消息
1 | %ROCKETMQ_HOME%/bin/tools org.apache.rocketmq.example.quickstart.Consumer |
ConsumeMessageThread_2 Receive New Messages: [MessageExt [queueId=1, storeSize=180, queueOffset=249, sysFlag=0, bornTimestamp=1510233930866, bornHost=/10.0.191.133:10130, storeTimestamp=1510233930867, storeHost=/10.0.191.133:10911, msgId=0A00BF8500002A9F000000000002BC96, commitLogOffset=179350, bodyCRC=1102156316, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message [topic=TopicTest, flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=250, CONSUME_START_TIME=1510233997434, UNIQ_KEY=0A00BF859C787EA987AC2DCBCC7203E5, WAIT=true, TAGS=TagA}, body=18]]]
ConsumeMessageThread_1 Receive New Messages: [MessageExt [queueId=1, storeSize=180, queueOffset=248, sysFlag=0, bornTimestamp=1510233930852, bornHost=/10.0.191.133:10130, storeTimestamp=1510233930854, storeHost=/10.0.191.133:10911, …
停止服务
停止 Broker
1 | %ROCKETMQ_HOME%/bin/mqshutdown broker |
killing broker
成功: 已终止 PID 为 42376 的进程。
Done!
停止 NameServer
1 | %ROCKETMQ_HOME%/bin/mqshutdown namesrv |
killing name server
成功: 已终止 PID 为 39464 的进程。
Done!