How can we retrieve the status of the RocketMQ cluster?
There are two methods available for obtaining the status of a RocketMQ cluster.
- You can use the command line tools provided by RocketMQ to retrieve the status of the cluster. The specific command is:
- Show the list of clusters in the MQ system using the specified Name Server address.
- Among them,
is the address of the NameServer. - This command will retrieve the status information of all Brokers and NameServers, including the ID, IP, version information, and status of each Broker.
- RocketMQ provides a Java API to retrieve the status of the cluster. Here is the specific code using the RocketMQ Java API.
- Create a DefaultMQAdminExt object and set the nameserver address. Start the admin and obtain cluster information about brokers. Iterate through the broker data, printing out the broker’s name and address. Handle any exceptions that may occur and shut down the admin when finished.
- In this code snippet, ‘
‘ represents the address of the NameServer. By invoking the admin.examineBrokerClusterInfo() method, the status information of the cluster is obtained, and then each Broker’s ID, IP, version information, and status are printed out by iterating through them.
Whether using command line tools or Java API, it is necessary to specify the address of the NameServer.