diff --git a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java index 2a8bc1cd806..117a41a1da9 100644 --- a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java +++ b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java @@ -23,6 +23,7 @@ import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.common.utils.NamedThreadFactory; +import org.apache.dubbo.common.utils.UrlUtils; import org.apache.dubbo.registry.NotifyListener; import org.apache.dubbo.registry.support.FailbackRegistry; import org.apache.dubbo.rpc.RpcException; @@ -142,7 +143,7 @@ public void doSubscribe(URL url, NotifyListener listener) { List services = getHealthServices(response.getValue()); urls = convert(services, url); } else { - String service = url.getServiceKey(); + String service = url.getServiceInterface(); Response> response = getHealthServices(service, -1, buildWatchTimeout(url)); index = response.getConsulIndex(); urls = convert(response.getValue(), url); @@ -256,6 +257,7 @@ private List convert(List services, URL consumerURL) { .filter(m -> m != null && m.containsKey(URL_META_KEY)) .map(m -> m.get(URL_META_KEY)) .map(URL::valueOf) + .filter(url -> UrlUtils.isMatch(consumerURL, url)) .collect(Collectors.toList()); } @@ -275,7 +277,7 @@ private NewService buildService(URL url) { service.setAddress(url.getHost()); service.setPort(url.getPort()); service.setId(buildId(url)); - service.setName(url.getServiceKey()); + service.setName(url.getServiceInterface()); service.setCheck(buildCheck(url)); service.setTags(buildTags(url)); service.setMeta(Collections.singletonMap(URL_META_KEY, url.toFullString()));