You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2023/01/05 02:36:54 UTC
[dubbo] branch 3.2 updated: Enhance nacos service discovery update (#11239)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new 4b4de1dd74 Enhance nacos service discovery update (#11239)
4b4de1dd74 is described below
commit 4b4de1dd7419cd131b6f11844298ea016c9f7430
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Thu Jan 5 10:36:29 2023 +0800
Enhance nacos service discovery update (#11239)
---
.../apache/dubbo/registry/nacos/NacosServiceDiscovery.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java
index f2b3c2d4ba..890b97be27 100644
--- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java
+++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java
@@ -46,6 +46,8 @@ import com.alibaba.nacos.api.naming.pojo.ListView;
import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_NACOS_EXCEPTION;
import static org.apache.dubbo.common.function.ThrowableConsumer.execute;
+import static org.apache.dubbo.metadata.RevisionResolver.EMPTY_REVISION;
+import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getExportedServicesRevision;
import static org.apache.dubbo.registry.nacos.util.NacosNamingServiceUtils.createNamingService;
import static org.apache.dubbo.registry.nacos.util.NacosNamingServiceUtils.getGroup;
import static org.apache.dubbo.registry.nacos.util.NacosNamingServiceUtils.toInstance;
@@ -98,6 +100,18 @@ public class NacosServiceDiscovery extends AbstractServiceDiscovery {
});
}
+ @Override
+ protected void doUpdate(ServiceInstance oldServiceInstance, ServiceInstance newServiceInstance) throws RuntimeException {
+ // register first to ensure that consumer will not throw no provider exception
+ if (!EMPTY_REVISION.equals(getExportedServicesRevision(serviceInstance))) {
+ reportMetadata(serviceInstance.getServiceMetadata());
+ this.serviceInstance = newServiceInstance;
+ this.doRegister(newServiceInstance);
+ }
+
+ this.doUnregister(oldServiceInstance);
+ }
+
@Override
public Set<String> getServices() {
return ThrowableFunction.execute(namingService, service -> {