RocketMQ原理解析-broker 1. broker的启动

brker的启动


Broker向namesrv注册

1.      获取namesrv的地址列表(是乱序的)

2.      遍历向每个namesrv注册topic的配置信息topicconfig

Topic在broker文件上的存储json格式

"TopicTest":{

                            "perm":6,

                            "readQueueNums":8,

                            "topicFilterType":"SINGLE_TAG",

                            "topicName":"TopicTest",

                            "writeQueueNums":8

                   }

 

Namesrv接收Broker注册的topic信息, namesrv只存内存,但是broker有任务定时推送

1.      接收数据向RouteInfoManager注册。

 

 

Broker初始化加载本地配置,配置信息是以json格式存储在本地, rocketmq强依赖fastjson作转换, RocketMq通过ConfigMananger来管理配置加载以及持久化


1.      加载topic配置${user.home}/store/config/topics.json

{

"dataVersion":{

           "counter":2,

           "timestatmp":1393729865073

},

"topicConfigTable":{

           //根据consumer的group生成的重试topic

           "%RETRY% group_name":{

                    "perm":6,

                    "readQueueNums":1,

                    "topicFilterType":"SINGLE_TAG",

                    "topicName":"%RETRY%group_name",

                    "writeQueueNums":1

           },

           "TopicTest":{

                    "perm":6,  // 100读权限 , 10写权限   6是110读写权限

                    "readQueueNums":8,

                    "topicFilterType":"SINGLE_TAG",

                    "topicName":"TopicTest",

                    "writeQueueNums":8

           }

}

}

2.      加载消费进度偏移量  ${user.home}/store/config/consumerOffset.json

{

"offsetTable":{

            "%RETRY% group_name@group_name":{

0:0 //重试队列消费进度为零

           },      

"TopicTest@ group_name":{

0:23,1:23,2:22,3:22,4:21,5:18,6:18,7:18

//分组名group_name消费topic为TopicTest的进度为:

// 队列queue=0  消费进度23

// 队列 queue=2  消费进度为22  等等…

           }

}

}

3.      加载消费者订阅关系 ${user.home}/store/config/subscriptionGroup.json

  {

         "dataVersion":{

                   "counter":1,

                   "timestatmp":1393641744664

         },

         "group_name":{

                            "brokerId":0,  //0代表这台broker机器为master,若要设为slave值大于0

                            "consumeBroadcastEnable":true,

                            "consumeEnable":true,

                            "consumeFromMinEnable":true,

                            "groupName":"group_name",

                            "retryMaxTimes":5,

                            "retryQueueNums":1,

                            "whichBrokerWhenConsumeSlowly":1

                   }

         }

}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值