Article Directory
1 RocketMq message queue function
1 异步解耦:不需要即时同步,如用户注册后的短信邮件通知,通知消息异步处理
2 流量削峰:如秒杀业务的消息通知,通知消息异步处理
Other queues: activeMq, kafka slightly;
2 Build a simple rmq environment under the centos of vm
Requirements: Linux system x64, jdk8+
2.1 Download the installation packagehttp://rocketmq.apache.org/release_notes/release-notes-4.4.0/
2.2 Installation, upload to /usr/local/src,
- 1 Enter the compressed file directory: cd /usr/lcoal/src
- 2 Unzip the file: unzip xxx.zip
- If there is no decompression command, please install it first: yum install zip unzip
- 3 Move the decompressed folder: mv rocketmq-xxxx /usr/local/rocketmq
2.3 Start nameServer and broker
- 1 Enter the startup directory:
cd /usr/local/rocketmq/bin
- 2 Start nameServer:
nohup ./mqnamesrv &
- 3 Test:
tail -f ~/logs/rokectmqlogs/namesrv.log
- Display
The Name Server boot success
indicates success
- Display
- 4 Test port: netstat -an | grep 9876
- If there is no netstat command, please install it first: yum install net-tools
- Port exists, indicating success
2.4 Start the broker
- 1 Edit bin/runbroker.sh, bin/runserver.sh, modify the value of parameter JAVA_OPT -Xms256m -Xmx256m -Xmn128m
- 2 Start
nohup ./mqbroker -n localhost:9876 &
- 3 test
tail -f ~/logs/rocketmqlogs/broker.log
- Show boot success means success
2.4 Testing
- 1 Open two windows, one for sending and one for receiving, and enter the bin directory
- 2 Send the command:
export NAMESRV_ADDR=localhost:9876
./tools.sh org.apache.rocketmq.example.quickstart.Producer
- 3 Receive commands:
export NAMESRV_ADDR=localhost:9876
./tools.sh org.apache.rocketmq.example.quickstart.Consumer
- 4 After receiving it, it has been monitoring the state. If you execute the transmission again, you can find that the receiving window receives the second time
2.5 Close mq
./mqshutdown broker
./mqshutdown namesrv
3 rocketMq console installation
- 1 Download
https://github.com/apache/rocketmq-externals/releases
, select console to download - 2 Modify the startup class rocketmq-console\src\main\resources\application.properties
server.port=7777
rocketmq.config.namesrvAddr=192.168.149.11:9876
- 3 Compile the jar package and execute
mvn clean package -Dmaven.test.skip=true
- 4 Upload to vm's /usr/local/src, start
java -jar r-xx.jar
- 5 Test, browser access
http://192.168.149.11:7777