- mvn -Prelease-all -DskipTests clean install -U
必须安装1.8+的jdk版本,并且在profile中配置好JAVA_HOME等环境变量,不能使用jre版本
- 启动brocker
启动后看tail -f ~/logs/rocketmqlogs/broker_default.log 出现下面这段就启动成功
![](https://img-blog.csdnimg.cn/img_convert/016b4362f3986ff5c9c92b9539f9f8fe.png)
- 启动ProducerExample和PushConsumerExample
复制官方的代码有几处要修改的地方,首先要保证linux虚拟机能跟主机通信。
ProducerExample
![](https://img-blog.csdnimg.cn/img_convert/890c3a2d7010f7b2d7192e7b35f9754c.png)
将“localhost:8081”修改为“linux虚拟机ip:8081”
将“Your Topic”修改为你创建的topic(sh bin/mqadmin updatetopic -n localhost:9876 -t TestTopic ——>创建topic语句)没有创建的话默认有一个TopicTest
可以使用rocketmq的dashboard或者用sh mqadmin topicList -n ip地址:9876查看所有topic
![](https://img-blog.csdnimg.cn/img_convert/7a837b142ba6b74df16b2df31a757ceb.png)
需要设置超时时间,默认的超时时间太短,建议设置为6000秒
![](https://img-blog.csdnimg.cn/img_convert/765aea5a891fbed847f2232458e9b200.png)
报错信息:
![](https://img-blog.csdnimg.cn/img_convert/0263f98c1a63b55aae0e7b0b52a96926.png)
PushConsumerExample
![](https://img-blog.csdnimg.cn/img_convert/fbb26b0974de59954e82e9ca001a0783.png)
同上需要设置超时时间
![](https://img-blog.csdnimg.cn/img_convert/639f32d145433560488c966342ef520a.png)
![](https://img-blog.csdnimg.cn/img_convert/9094cc4c0da88356fbfb05c32fd42733.png)
需要修改为自己的Group和Topic
查看所有消费组group: sh mqadmin consumerProgress -n 本机IP:9876
查看所有topic : sh mqadmin topicList -n 本机IP:9876