diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java index 8555cf142c..f0f2a6fc98 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java @@ -42,6 +42,8 @@ import java.util.concurrent.CountDownLatch; import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION; import static org.apache.dubbo.common.function.ThrowableFunction.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.zookeeper.util.CuratorFrameworkUtils.build; import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.buildCuratorFramework; import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.buildServiceDiscovery; @@ -106,6 +108,19 @@ public class ZookeeperServiceDiscovery extends AbstractServiceDiscovery { } } + @Override + protected void doUpdate(ServiceInstance serviceInstance) throws RuntimeException { + if (!EMPTY_REVISION.equals(getExportedServicesRevision(serviceInstance))) { + reportMetadata(serviceInstance.getServiceMetadata()); + } + + try { + serviceDiscovery.updateService(build(serviceInstance)); + } catch (Exception e) { + throw new RpcException(REGISTRY_EXCEPTION, "Failed register instance " + serviceInstance.toString(), e); + } + } + @Override public Set getServices() { return doInServiceDiscovery(s -> new LinkedHashSet<>(s.queryForNames()));