---
title: "rocketMq实战(5)-本地调试broker源码"
author: "chenchangqun"
date: "2016-12-15T17:55:10Z"
tags: ["debug"]
categories: ["开源软件"]
slug: "rocketmq-5-broker"
draft: false
lastmod: "2016-12-15T17:55:10Z"
id: 2345106
url: "https://chenchangqun.iteye.com/blog/2345106"
---

源码下载地址：[https://github.com/alibaba/RocketMQ](https://github.com/alibaba/RocketMQ)

配置好的项目如下图

![](http://dl2.iteye.com/upload/attachment/0121/9982/efa8eb90-b2de-3e8a-b4b0-869e20388ef1.png)  
 

broker 的启动类 ： com.alibaba.rocketmq.broker.BrokerStartup

broker启动 需要加载配置文件，如下

![](http://dl2.iteye.com/upload/attachment/0121/9984/256aae94-08ec-3004-841a-647f84a4e812.png)  
 **broker-c.properties**

brokerClusterName=DefaultCluster

brokerName=broker-c

brokerId=0

listenPort=10911

deleteWhen=04

fileReservedTime=48

brokerRole=ASYNC\_MASTER

flushDiskType=ASYNC\_FLUSH

 

**配置debug Application**

![](http://dl2.iteye.com/upload/attachment/0121/9986/bee5953a-faa5-3cc4-97bb-e06fc3f7ebbd.png)  
 

 

参数配置如图

-n "10.103.16.77:9876;10.103.16.15:9876" -c E:/work\_file/RocketMq/r-config/broker-c.properties

![](http://dl2.iteye.com/upload/attachment/0121/9988/64f7392f-4a2e-33fb-966f-0ac18799e3fc.png)

 运行 遇到以下问题

"Please set the ROCKETMQ\_HOME variable in your environment to match the location of the RocketMQ installation"

原因是 没有获取到 ROCKETMQ\_HOME，set相应的目录即可

BrokerStartup：

![](http://dl2.iteye.com/upload/attachment/0121/9990/0617f224-2bdb-345e-a5f3-a175f3598d31.png)  
 debug成功如下

![](http://dl2.iteye.com/upload/attachment/0121/9992/6b221e0b-f888-36e1-84b3-c637c7f5d17c.png)