1. 準備
前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。
64bit OS, Linux/Unix/Mac?
64bit JDK 1.8+;
Maven 3.2.x
2.下載和構建
下載 4.2.0 源代碼版本地址:http://mirrors.hust.edu.cn/apache/rocketmq/4.2.0/rocketmq-all-4.2.0-source-release.zip
現在執行以下命令來解壓縮 4.2.0 源代碼版本并構建二進制工件。
> unzip rocketmq-all-4.2.0-source-release.zip> cd rocketmq-all-4.2.0/> mvn -Prelease-all -DskipTests clean install -U> cd distribution/target/apache-rocketmq
3.啟動mqnamesrv? 、mqbroker?
> nohup sh bin/mqnamesrv &> tail -f ~/logs/rocketmqlogs/namesrv.log運行成功的日志輸出:The Name Server boot success...官方啟動 broker 方式如下:> nohup sh bin/mqbroker -n localhost:9876 &
經測試這樣是不行的,要在后面加上設置 : autoCreateTopicEnable=true 。最終運行命令為:(nohup 記錄日志,& 表示后臺運行 )> nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true &> tail -f ~/logs/rocketmqlogs/broker.log 運行成功的日志輸出:The broker[%s, 172.30.30.233:10911] boot success...
?4.修改配置、發送和接收消息
設置環境變量> export NAMESRV_ADDR=localhost:9876啟動生產者> sh bin/tools.sh org.apache.rocketmq.example.quickstart.ProducerSendResult [sendStatus=SEND_OK, msgId= ...啟動消費者> sh bin/tools.sh org.apache.rocketmq.example.quickstart.ConsumerConsumeMessageThread_%d Receive New Messages: [MessageExt...
5.關閉服務
> 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
6.踩過的坑
1)報錯: There is insufficient memory for the Java Runtime Environment to continue
解決方式:??解決There is insufficient memory for the Java Runtime Environment to continue
2)報錯:org.apache.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest
解決方式:解決:org.apache.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest
3)報錯:Could not find or load main class org.apache.rocketmq.example.quickstart.Producer
解決方式:解決:Could not find or load main class org.apache.rocketmq.example.quickstart.Producer
?
參考官方文檔:https://rocketmq.apache.org/docs/quick-start/