diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java index 65dd90f7a1235..4f963a496977b 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java @@ -338,6 +338,12 @@ public PulsarService(ServiceConfiguration config, // the advertised address is defined as the host component of the broker's canonical name. this.advertisedAddress = ServiceConfigurationUtils.getDefaultOrConfiguredAddress(config.getAdvertisedAddress()); + // the broker id is used in the load manager to identify the broker + // it should not be used for making connections to the broker + this.brokerId = + String.format("%s:%s", advertisedAddress, config.getWebServicePort() + .or(config::getWebServicePortTls).orElseThrow()); + // use `internalListenerName` listener as `advertisedAddress` this.bindAddress = ServiceConfigurationUtils.getDefaultOrConfiguredAddress(config.getBindAddress()); this.brokerVersion = PulsarVersion.getVersion(); @@ -918,12 +924,6 @@ public void start() throws PulsarServerException { this.brokerServiceUrl = brokerUrl(config); this.brokerServiceUrlTls = brokerUrlTls(config); - // the broker id is used in the load manager to identify the broker - // it should not be used for making connections to the broker - this.brokerId = - String.format("%s:%s", advertisedAddress, config.getWebServicePort() - .or(config::getWebServicePortTls).orElseThrow()); - if (this.compactionServiceFactory == null) { this.compactionServiceFactory = loadCompactionServiceFactory(); }