This quick start guide is a detailed instruction of setting up RocketMQ messaging system on your local machine to send and receive messages.
More Details:
The following softwares are assumed installed:
Click here to download the 4.8.0 source release. Also you could download a binary release from here.
Now execute the following commands to unpack 4.8.0 source release and build the binary artifact.
> unzip rocketmq-all-4.8.0-source-release.zip > cd rocketmq-all-4.8.0/ > mvn -Prelease-all -DskipTests clean install -U > cd distribution/target/rocketmq-4.8.0/rocketmq-4.8.0
> nohup sh bin/mqnamesrv & > tail -f ~/logs/rocketmqlogs/namesrv.log The Name Server boot success...
> nohup sh bin/mqbroker -n localhost:9876 & > tail -f ~/logs/rocketmqlogs/broker.log The broker[%s, 172.30.30.233:10911] boot success...
Before sending/receiving messages, we need to tell clients the location of name servers. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable 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
The guide is working for windows 10 , please make sure you have powershell installed.
Download latest binary release. and extract zip file into your local disk. Such as: D:\rocketmq
You need set environment variables
ROCKETMQ_HOME="D:\rocketmq" NAMESRV_ADDR="localhost:9876"
Or just in the openning powershell, type the needed environment variables.
$Env:ROCKETMQ_HOME="D:\rocketmq" $Env:NAMESRV_ADDR="localhost:9876"
If you choose the powershell way. you should do it for every new open powershell window.
Open new powershell window, after set the correct environment variable. then change directory to rocketmq type and run:
.\bin\mqnamesrv.cmd
Open new powershell window, after set the correct environment variable. then change directory to rocketmq type and run:
.\bin\mqbroker.cmd -n localhost:9876 autoCreateTopicEnable=true
Open new powershell window, after set the correct environment variable. then change directory to rocketmq type and run:
.\bin\tools.cmd org.apache.rocketmq.example.quickstart.Producer
Then you will see messages produced. and now we can try consumer messages.
Open new powershell window, after set the correct environment variable. then change directory to rocketmq type and run:
.\bin\tools.cmd org.apache.rocketmq.example.quickstart.Consumer
Normally, you can just closed these powershell windows. (Do not do it at production environment)