id: admin-api-brokers title: Managing Brokers sidebar_label: “Brokers”

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

:::tip

This page only shows some frequently used operations.

  • For the latest and complete information about Pulsar admin, including commands, flags, descriptions, and more information, see Pulsar admin doc.

  • For the latest and complete information about REST API, including parameters, responses, samples, and more, see {@inject: rest:REST:/} API doc.

  • For the latest and complete information about Java admin API, including classes, methods, descriptions, and more, see Java admin API doc.

:::

Pulsar brokers consist of two components:

  1. An HTTP server exposing a {@inject: rest:REST:/} interface administration and topic lookup.
  2. A dispatcher that handles all Pulsar message transfers.

Brokers can be managed via:

  • The brokers command of the pulsar-admin tool
  • The /admin/v2/brokers endpoint of the admin {@inject: rest:REST:/} API
  • The brokers method of the PulsarAdmin object in the Java API

In addition to being configurable when you start them up, brokers can also be dynamically configured.

See the Configuration page for a full listing of broker-specific configuration parameters.

Brokers resources

List active brokers

Fetch all available active brokers that are serving traffic with cluster name.

<Tabs groupId="api-choice"
  defaultValue="pulsar-admin"
  values={[{"label":"pulsar-admin","value":"pulsar-admin"},{"label":"REST API","value":"REST API"},{"label":"Java","value":"Java"}]}>
<TabItem value="pulsar-admin">

```shell

$ pulsar-admin brokers list use
broker1.use.org.com:8080

```

</TabItem>
<TabItem value="REST API">

{@inject: endpoint|GET|/admin/v2/brokers/:cluster|operation/getActiveBrokers?version=@pulsar:version_number@}

</TabItem>
<TabItem value="Java">

```java

admin.brokers().getActiveBrokers(clusterName)

```

</TabItem>

</Tabs>

Get the information of the leader broker

Fetch the information of the leader broker, for example, the service url.

<Tabs groupId="api-choice"
  defaultValue="pulsar-admin"
  values={[{"label":"pulsar-admin","value":"pulsar-admin"},{"label":"REST API","value":"REST API"},{"label":"Java","value":"Java"}]}>
<TabItem value="pulsar-admin">

```shell

$ pulsar-admin brokers leader-broker
BrokerInfo(serviceUrl=broker1.use.org.com:8080)

```

</TabItem>
<TabItem value="REST API">

{@inject: endpoint|GET|/admin/v2/brokers/leaderBroker|operation/getLeaderBroker?version=@pulsar:version_number@}

</TabItem>
<TabItem value="Java">

```java

admin.brokers().getLeaderBroker()

```

For the detail of the code above, see [here](https://github.com/apache/pulsar/blob/master/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java#L80)

</TabItem>

</Tabs>

list of namespaces owned by a given broker

It finds all namespaces which are owned and served by a given broker.

<Tabs groupId="api-choice"
  defaultValue="pulsar-admin"
  values={[{"label":"pulsar-admin","value":"pulsar-admin"},{"label":"REST API","value":"REST API"},{"label":"Java","value":"Java"}]}>
<TabItem value="pulsar-admin">

```shell

$ pulsar-admin brokers namespaces use \
  --url broker1.use.org.com:8080

{
  "my-property/use/my-ns/0x00000000_0xffffffff": {
    "broker_assignment": "shared",
    "is_controlled": false,
    "is_active": true
  }
}

```

</TabItem>
<TabItem value="REST API">

{@inject: endpoint|GET|/admin/v2/brokers/:cluster/:broker/ownedNamespaces|operation/getOwnedNamespaes?version=@pulsar:version_number@}

</TabItem>
<TabItem value="Java">

```java

admin.brokers().getOwnedNamespaces(cluster,brokerUrl);

```

</TabItem>

</Tabs>

Dynamic broker configuration

One way to configure a Pulsar broker is to supply a configuration when the broker is started up.

But since all broker configuration in Pulsar is stored in ZooKeeper, configuration values can also be dynamically updated while the broker is running. When you update broker configuration dynamically, ZooKeeper will notify the broker of the change and the broker will then override any existing configuration values.

  • The brokers command for the pulsar-admin tool has a variety of subcommands that enable you to manipulate a broker's configuration dynamically, enabling you to update config values and more.
  • In the Pulsar admin {@inject: rest:REST:/} API, dynamic configuration is managed through the /admin/v2/brokers/configuration endpoint.

Update dynamic configuration

<Tabs groupId="api-choice"
  defaultValue="pulsar-admin"
  values={[{"label":"pulsar-admin","value":"pulsar-admin"},{"label":"REST API","value":"REST API"},{"label":"Java","value":"Java"}]}>
<TabItem value="pulsar-admin">

The [`update-dynamic-config`](/tools/pulsar-admin/) subcommand will update existing configuration. It takes two arguments: the name of the parameter and the new value using the `config` and `value` flag respectively. Here's an example for the [`brokerShutdownTimeoutMs`](reference-configuration.md#broker-brokerShutdownTimeoutMs) parameter:

```shell

$ pulsar-admin brokers update-dynamic-config --config brokerShutdownTimeoutMs --value 100

```

</TabItem>
<TabItem value="REST API">

{@inject: endpoint|POST|/admin/v2/brokers/configuration/:configName/:configValue|operation/updateDynamicConfiguration?version=@pulsar:version_number@}

</TabItem>
<TabItem value="Java">

```java

admin.brokers().updateDynamicConfiguration(configName, configValue);

```

</TabItem>

</Tabs>

List updated values

Fetch a list of all potentially updatable configuration parameters.

<Tabs groupId="api-choice"
  defaultValue="pulsar-admin"
  values={[{"label":"pulsar-admin","value":"pulsar-admin"},{"label":"REST API","value":"REST API"},{"label":"Java","value":"Java"}]}>
<TabItem value="pulsar-admin">

```shell

$ pulsar-admin brokers list-dynamic-config
brokerShutdownTimeoutMs

```

</TabItem>
<TabItem value="REST API">

{@inject: endpoint|GET|/admin/v2/brokers/configuration|operation/getDynamicConfigurationName?version=@pulsar:version_number@}

</TabItem>
<TabItem value="Java">

```java

admin.brokers().getDynamicConfigurationNames();

```

</TabItem>

</Tabs>

List all

Fetch a list of all parameters that have been dynamically updated.

<Tabs groupId="api-choice"
  defaultValue="pulsar-admin"
  values={[{"label":"pulsar-admin","value":"pulsar-admin"},{"label":"REST API","value":"REST API"},{"label":"Java","value":"Java"}]}>
<TabItem value="pulsar-admin">

```shell

$ pulsar-admin brokers get-all-dynamic-config
brokerShutdownTimeoutMs:100

```

</TabItem>
<TabItem value="REST API">

{@inject: endpoint|GET|/admin/v2/brokers/configuration/values|operation/getAllDynamicConfigurations?version=@pulsar:version_number@}

</TabItem>
<TabItem value="Java">

```java

admin.brokers().getAllDynamicConfigurations();

```

</TabItem>

</Tabs>