From fb2971bf8c628a1bcf437bf824420d46f30f8cf8 Mon Sep 17 00:00:00 2001 From: Fishtail <49390359+fuyuwei01@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:48:45 +0800 Subject: [PATCH] feat:support consul service update task. (#1413) Co-authored-by: Haotian Zhang --- CHANGELOG.md | 1 + .../registry/PolarisAutoServiceRegistration.java | 5 ----- spring-cloud-tencent-dependencies/pom.xml | 2 +- .../tsf-example/consumer-demo/pom.xml | 12 +++++++++++- .../tsf-example/provider-demo/pom.xml | 12 +++++++++++- .../tsf/env/TsfCoreEnvironmentPostProcessor.java | 3 +++ 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a811f43e..316283464 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,3 +22,4 @@ - [feat:support consul config.](https://github.com/Tencent/spring-cloud-tencent/pull/1410) - [feat:add trace report support.](https://github.com/Tencent/spring-cloud-tencent/pull/1411) - [fix: fix lossless test case unstable issues.](https://github.com/Tencent/spring-cloud-tencent/pull/1412) +- [feat:support consul service update task.](https://github.com/Tencent/spring-cloud-tencent/pull/1413) diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisAutoServiceRegistration.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisAutoServiceRegistration.java index 96b359096..563ec8ef6 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisAutoServiceRegistration.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisAutoServiceRegistration.java @@ -17,9 +17,7 @@ package com.tencent.cloud.polaris.registry; -import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.polaris.PolarisDiscoveryProperties; -import com.tencent.polaris.api.pojo.ServiceKey; import com.tencent.polaris.assembly.api.AssemblyAPI; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,9 +71,6 @@ public class PolarisAutoServiceRegistration extends AbstractAutoServiceRegistrat LOGGER.debug("Registration disabled."); return; } - if (assemblyAPI != null) { - assemblyAPI.initService(new ServiceKey(MetadataContext.LOCAL_NAMESPACE, MetadataContext.LOCAL_SERVICE)); - } super.register(); } diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index caffb6532..59aeffbe0 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -74,7 +74,7 @@ 1.14.0-2023.0.0-RC2 - 1.15.7-SNAPSHOT + 1.15.8-SNAPSHOT 32.0.1-jre diff --git a/spring-cloud-tencent-examples/tsf-example/consumer-demo/pom.xml b/spring-cloud-tencent-examples/tsf-example/consumer-demo/pom.xml index ca0dc4358..6c839dd70 100644 --- a/spring-cloud-tencent-examples/tsf-example/consumer-demo/pom.xml +++ b/spring-cloud-tencent-examples/tsf-example/consumer-demo/pom.xml @@ -14,7 +14,17 @@ com.tencent.cloud - spring-cloud-starter-tencent-all + spring-cloud-starter-tencent-polaris-discovery + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-config + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-contract diff --git a/spring-cloud-tencent-examples/tsf-example/provider-demo/pom.xml b/spring-cloud-tencent-examples/tsf-example/provider-demo/pom.xml index 202b268a8..f5ed608fc 100644 --- a/spring-cloud-tencent-examples/tsf-example/provider-demo/pom.xml +++ b/spring-cloud-tencent-examples/tsf-example/provider-demo/pom.xml @@ -14,7 +14,17 @@ com.tencent.cloud - spring-cloud-starter-tencent-all + spring-cloud-starter-tencent-polaris-discovery + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-config + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-contract diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/tsf/env/TsfCoreEnvironmentPostProcessor.java b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/tsf/env/TsfCoreEnvironmentPostProcessor.java index 05a706c68..1ebd2d2bc 100644 --- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/tsf/env/TsfCoreEnvironmentPostProcessor.java +++ b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/tsf/env/TsfCoreEnvironmentPostProcessor.java @@ -77,6 +77,9 @@ public final class TsfCoreEnvironmentPostProcessor implements EnvironmentPostPro if (StringUtils.isBlank(tsfNamespaceId)) { LOGGER.error("tsf_namespace_id is empty"); } + else { + defaultProperties.put("spring.cloud.polaris.namespace", tsfNamespaceId); + } // tsf_consul_ip String tsfConsulIp = environment.getProperty("tsf_consul_ip");