5-RocketMQ-NameServer

Time:2021-7-26

Routing meta information

Nameserver routing implementation class: org.apache.rocketmq.namesrv.routeinfo.routeinfomanager. Before understanding routing registration, let’s first look at what information nameserver stores.

private final HashMap<String/* topic */, List<QueueData>> topicQueueTable;
private final HashMap<String/* brokerName */, BrokerData> brokerAddrTable;
private final HashMap<String/* clusterName */, Set<String/* brokerName */>> clusterAddrTable;
private final HashMap<String/* brokerAddr */, BrokerLiveInfo> brokerLiveTable;
private final HashMap<String/* brokerAddr */, List<String>/* Filter Server */> filterServerTable;

Topicqueuetable: topic message queue routing information. Load balancing is performed according to the routing table when sending messages.

Brokeraddrtable: the basic information of the broker, including the broker name, the cluster name, and the active and standby broker addresses.

Brokerlivetable: broker status information. Nameserver replaces this information every time it receives a heartbeat packet.

Filterservertable: the filterserver list on the broker, which is used for class mode message filtering,

public class QueueData implements Comparable<QueueData> {

Multiple brokers form a cluster. The broker name consists of the same multiple brokers to form the master slave architecture. A broker ID of 0 represents the master, and greater than 0 represents the slave.

5-RocketMQ-NameServer

5-RocketMQ-NameServer

5-RocketMQ-NameServer

Route registration

Rocketmq route registration is realized through the heartbeat function of broker and nameserver. When the broker is started, it sends heartbeat statements to all nameservers in the cluster, and sends heartbeat packets to all nameservers in the cluster every 30s. When the nameserver receives the broker heartbeat packet, it will update the lastupdate timestamp of the brokerliveinfo in the brokerlivetable cache, and then the nameserver scans the brokerlivetable every 10s. If no heartbeat packet is received for 120s, Nameserver will remove the routing information of the broker and close the socket connection.

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Recommended Today

Implementation example of go operation etcd

etcdIt is an open-source, distributed key value pair data storage system, which provides shared configuration, service registration and discovery. This paper mainly introduces the installation and use of etcd. Etcdetcd introduction etcdIt is an open source and highly available distributed key value storage system developed with go language, which can be used to configure sharing […]