Namesrv Name Service, is no state can be clustered horizontally.
1. Each broker starts with a 2 registration to Namesrv . Producer gets the information that is routed to the broker when the message is sent by Topic 3. Consumer topic to NAMESRV to obtain topic routing to broker information
One: namesrv function:
Requests from the receiving broker to register broker routing information (both master and slave) receive client requests based on a topic to obtain all routing information to the broker
II: NAMESRV Start-up process:
Three: Routeinfomanager
Management of routing information Routeinfomanager class
Brokername represents a set of brokers, such as a brokername=broker-A, which may include a master with its multiple slavemap<brokername, brokerdata> Brokerdata whether the brokername and its broker IDs and address IDs represent master or slave id= 0 for master greater than 0 for Slavemap <topic, list<queuedata>>queuedata by brokername, read queue number, write queue number, already permission value map<clustername,set <brokerName>> The broker is grouped by cluster map<brokeraddr, brokerliveinfo> brokerliveinfo Represents a live broker link by the last update time, a link channel, data version and HA address that comprise the broker timed to register with NAMESRV and update Brokerliveinfo timestamp
Four: The heartbeat between Namesrv and broker:
1. When the broker starts, it initiates a timed task, sending a heartbeat request to all namesrv every 10 seconds, as well as registering topic information to NAMESRV2. Namesrv receive Register_broke event handling for Borker Heartbeat Defaultrequestprocessor, (1) Register Broker's topic information (2) Build or update the timestamp of Brokerliveinfo 3. Namesrvcontroller initialization thread periodically calls Routeinfomanger's Scannotactivebroker method to periodically clean up the inactive broker
(Default two minutes does not send heartbeat update to NAMESRV brokerliveinfo timestamp), compare Brokerliveinfo timestamp, close channel connection if expired
ROCKETMQ Principle Analysis-nameserver