Rocketmq source compiler run
download
From github download the source code, more slowly, also from gitee download
Source Directory Structure
name | effect |
---|---|
broker | broker modules: c p and an end message store logic |
client | The client api: produce, consumer acceptance and sending end api |
common | Common Components: Constant base class, the data structure |
tools | Operation and maintenance tools: command-line tool module |
store | Memory module: message index, commitlog storage |
namesrv | Service Management modules: service registration information storage topic |
remoting | Remote Communication Module: netty + fastjson |
logappender | Log adaptation module |
example | Demo Liezi |
filtersrv | Message filter module |
srvutil | Auxiliary Module |
filter | Filter module: message filtering module |
distribution | Deployment, operation and maintenance related to the zip code |
openmessaging | Compatible openmessaging distributed messaging module |
Compile
Decompression Import idea, modify the configuration file pom.xml, jdk compiled version 1.8
# 编译
mvn -Prelease-all -DskipTests clean install -U
Start namesrv
Enter org.apache.rocketmq.namesrv.NamesrvStartup, execute the main method
It throws an error, because there is no set path to the configuration file ROCKETMQ_HOME
Please set the ROCKETMQ_HOME variable in your environment to match the lo
cation of the RocketMQ installation
Code location org.apache.rocketmq.namesrv.NamesrvStartup # createNamesrvController, modify the source, increase configuration rocketHome
RocketHome may be provided by modifying the boot parameters, in the configuration parameters for the VM run configurators idea of
-Drocketmq.home.dir = D: \ code \ java_yuanma \ rocketmq \ distribution
It also needs to be set user.home, specify the log file path
-Duser.home=D:\code\java_yuanma\rocketmq\user.home
还需要配置namesrv的ip和port
然后运行NamesrvStartup#main启动namesrv
控制台出现上图结果,启动成功
启动broker
进入org.apache.rocketmq.broker.BrokerStartup,可以执行main方法,同样需要先配置rocketHome
在org.apache.rocketmq.broker.BrokerStartup#createBrokerController中修改源码,增加rocketHome的配置
也可以通过修改启动参数设置rocketHome, 在idea的run configurators中配置 VM参数为
-Drocketmq.home.dir=D:\code\java_yuanma\rocketmq\distribution
同时还需要设置user.home,指定日志文件路径
-Duser.home=D:\code\java_yuanma\rocketmq\user.home
还需要配置程序参数
‐n 127.0.0.0:9876 -c D:\code\java_yuanma\rocketmq\distribution\conf\broker.conf
然后运行BrokerStartup#main启动broker
控制台出现上图结果,启动成功
如果出现以下情况,ip不对,是因为多网卡的问题
这时需要修改D:\code\java_yuanma\rocketmq\distribution\conf\broker.conf 此配置文件
增加brokerIP1 = 127.0.0.1
测试
启动Producer发消息,成功
如果出现No Topic Route Info 错误:
broker.conf 中增加配置
autoCreateTopicEnable = true
namesrvAddr = 127.0.0.1:9876