apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.4k stars 26.42k forks source link

dubbo register service name missing version,health check service failure! #6213

Closed yongyongwang closed 2 years ago

yongyongwang commented 4 years ago

environment : dubbo + consul

org.apache.dubbo dubbo-spring-boot-starter 2.7.6

org.apache.dubbo.registry.consul.ConsulRegistry

private NewService buildService(URL url) { NewService service = new NewService(); service.setAddress(url.getHost()); service.setPort(url.getPort()); service.setId(buildId(url)); service.setName(url.getServiceInterface()); service.setCheck(buildCheck(url)); service.setTags(buildTags(url)); service.setMeta(Collections.singletonMap(URL_META_KEY, url.toFullString())); return service; }

serviceName not contains dubbo service version

    <dependency>
        <groupId>com.ecwid.consul</groupId>
        <artifactId>consul-api</artifactId>
        <version>1.4.5</version>
    </dependency>

serverName contains service version

com.ecwid.consul.v1.health.HealthConsulClient

public Response<List<HealthService>> getHealthServices(String serviceName, HealthServicesRequest healthServicesRequest) {
    HttpResponse httpResponse = rawClient.makeGetRequest("/v1/health/service/" + serviceName, healthServicesRequest.asUrlParameters());

    if (httpResponse.getStatusCode() == 200) {
        List<com.ecwid.consul.v1.health.model.HealthService> value = GsonFactory.getGson().fromJson(httpResponse.getContent(),
                new TypeToken<List<com.ecwid.consul.v1.health.model.HealthService>>() {
                }.getType());
        return new Response<List<com.ecwid.consul.v1.health.model.HealthService>>(value, httpResponse);
    } else {
        throw new OperationException(httpResponse);
    }
}

dubbo service restart , dubbo consumer will not get dubbo service

yongyongwang commented 4 years ago

consul service name : interface name

health service name : interface name : version

yongyongwang commented 4 years ago

类名:org.apache.dubbo.registry.consul.ConsulRegistry

register service name private NewService buildService(URL url) { NewService service = new NewService(); service.setAddress(url.getHost()); service.setPort(url.getPort()); service.setId(buildId(url)); service.setName(url.getServiceInterface()); 接口名称 service.setCheck(buildCheck(url)); service.setTags(buildTags(url)); service.setMeta(Collections.singletonMap(URL_META_KEY, url.toFullString())); return service; }

health check service name: url.getServiceKey(); private void processService() { String service = url.getServiceKey(); 健康检查用了接口名称:版本号,不一致 Response<List> response = getHealthServices(service, consulIndex, buildWatchTimeout(url)); Long currentIndex = response.getConsulIndex(); if (currentIndex != null && currentIndex > consulIndex) { consulIndex = currentIndex; List services = response.getValue(); List urls = convert(services, url); for (NotifyListener listener : getSubscribed().get(url)) { doNotify(url, listener, urls); } } }

CrazyHZM commented 2 years ago

Try it with the latest version, if you still have problems, you can reopen the issue

LiPeng960419 commented 2 years ago

兄弟你的问题解决了吗?