From 17d141b4b624ce621e30785d907d0fc2d557578a Mon Sep 17 00:00:00 2001 From: Haotian Zhang Date: Fri, 15 Aug 2025 16:58:32 +0800 Subject: [PATCH] fix: polaris.discovery.heartbeat.enabled not effective. (#1713) Co-authored-by: zihenzzz <131673437+zihenzzz@users.noreply.github.com> --- CHANGELOG.md | 1 + .../polaris/PolarisDiscoveryProperties.java | 14 +++++++++++ .../registry/PolarisServiceRegistry.java | 23 ++++++++++++------- ...itional-spring-configuration-metadata.json | 6 +++++ .../PolarisDiscoveryPropertiesTest.java | 1 + 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7db052512..d611f6dad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,3 +19,4 @@ - [feat: support config event and monitor address list.](https://github.com/Tencent/spring-cloud-tencent/pull/1708) - [fix:replace HttpClient with HttpURLConnection for JDK 8 compatibility.](https://github.com/Tencent/spring-cloud-tencent/pull/1709) - [feat:Modify the annotations.](https://github.com/Tencent/spring-cloud-tencent/pull/1712) +- [fix: polaris.discovery.heartbeat.enabled not effective.](https://github.com/Tencent/spring-cloud-tencent/pull/1713) diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java index 5c7b3b5fe..4eb8d1fe6 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java @@ -83,6 +83,11 @@ public class PolarisDiscoveryProperties { @Value("${spring.cloud.polaris.discovery.register:#{true}}") private Boolean registerEnabled; + /** + * Enable heartbeat or not. + */ + private Boolean heartbeatEnabled = true; + /** * Heartbeat interval ( 0 < interval <= 60). * Time unit: second. Default: 5. @@ -208,6 +213,14 @@ public class PolarisDiscoveryProperties { this.serviceListRefreshInterval = serviceListRefreshInterval; } + public Boolean getHeartbeatEnabled() { + return heartbeatEnabled; + } + + public void setHeartbeatEnabled(Boolean heartbeatEnabled) { + this.heartbeatEnabled = heartbeatEnabled; + } + public Integer getHeartbeatInterval() { if (this.heartbeatInterval <= 0 || this.heartbeatInterval > 60) { heartbeatInterval = DEFAULT_REGISTRY_HEARTBEAT_TIME_INTERVAL; @@ -291,6 +304,7 @@ public class PolarisDiscoveryProperties { ", protocol='" + protocol + '\'' + ", enabled=" + enabled + ", registerEnabled=" + registerEnabled + + ", heartbeatEnabled=" + heartbeatEnabled + ", heartbeatInterval=" + heartbeatInterval + ", healthCheckUrl='" + healthCheckUrl + '\'' + ", serviceListRefreshInterval=" + serviceListRefreshInterval + diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java index 952b7c3be..58419a761 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java @@ -127,7 +127,6 @@ public class PolarisServiceRegistry implements ServiceRegistry