songxiaosheng opened a new issue, #12322:
URL: https://github.com/apache/dubbo/issues/12322

   # Dubbo Zookeeper and Spring Cloud Zoom Keeper Interconnection Solution
   
   # background
   
   Even when using the Http Rest protocol, there is still incompatibility 
between the Dubbo Zookeeper and Spring Cloud Zookeeper service discovery 
models. This is because there are differences in the implementation and 
protocol design of service registration and discovery between Dubbo and Spring 
Cloud. However, compatibility between them can be achieved through the 
following methods:
   
   1. **Using the same registry:**  Dubbo and Spring Cloud applications both 
use Zookeeper as the registry, and services can be interconnected by sharing 
the same Zookeeper instance.
      Use the same service registration protocol: You can configure the same 
service registration protocol, such as HTTP REST protocol or gRPC protocol, in 
both Dubbo and Spring Cloud applications to achieve compatibility between 
services.
   2. **Using adapter mode:**  You can write an adapter program that converts 
the Dubbo Zookeeper service registration and discovery model into a Spring 
Cloud Zookeeper service registration and discovery model, or convert the Spring 
Cloud Zookeeper service registration and discovery model into a Dubbo Zookeeper 
service registration and discovery model. This allows for compatibility 
conversion between Dubbo and Spring Cloud applications.
   
   # Service Discovery Model
   
   
   
   
[[service-discovery](https://cn.dubbo.apache.org/imgs/v3/feature/service-discovery/arc2.png)](https://cn.dubbo.apache.org/imgs/v3/feature/service-discovery/arc2.png)
   
   
   
   Service Discovery Document for Spring Cloud Zookeeper:
   
https://docs.spring.io/spring-cloud-zookeeper/docs/current/reference/html/#quick
 -start
   Dubbo's Service Discovery Model Document:
   https://cn.dubbo.apache.org/zh-cn/overview/core-features/service-discovery/
   
   # Compatible processing
   
   Regarding service discovery, it is necessary to achieve compatibility in the 
following locations
   
   1. Service provider online registration
   2.  Service consumer perception provider online
   3. Service provider offline destruction
   4. Service consumers perceive providers as offline
   5. Service consumers obtain metadata from service providers
   
   # Usage
   
   Dubbo Zookeeper and Spring Cloud Zookeeper are both service discovery and 
registration centers based on Zookeeper implementation. The interconnectivity 
solution between them can be achieved through the following steps:
   
   1. Configure Dubbo's registry as Zookeeper, and Spring Cloud's registry as 
Zookeeper.
   2. Expose services in Dubbo, configure service interfaces and implementation 
classes using @ Service annotations or XML configuration files, and configure 
service related information such as service name, version number, protocol, 
port, etc. in the Dubbo: service tag. At the same time, it is necessary to 
configure the Http Rest protocol in the dubbo: protocol tag.
   3. Register services in the Spring Cloud, use the @ EnableDiscoveryClient 
annotation to enable service registration and discovery, use the @ 
RestController or @ RequestMapping annotation to define the RESTful API 
interface, and call the services exposed by Dubbo in the interface 
implementation method.
      Referencing services in Dubbo, using @ Reference annotations or XML 
configuration files to configure service interfaces and implementation classes, 
and configuring service related information such as service name, version 
number, protocol, load balancing, etc. in the Dubbo: reference tag. At the same 
time, it is necessary to configure the Http Rest protocol in the dubbo: 
protocol tag.
   4. Call services in Spring Cloud, and use RestTemplate or FeignClient to 
send HTTP requests to call services referenced by Dubbo.
      Start the Dubbo and Spring Cloud applications, test whether the service 
registration and discovery functions are normal.
   5. Overall, the interconnection solution between Dubbo Zookeeper and Spring 
Cloud Zookeeper requires configuring service registration and discovery, as 
well as service referencing and invocation, in Dubbo and Spring Cloud 
applications. By sharing the Zookeeper registry, the interconnection between 
services can be achieved. At the same time, it is necessary to configure the 
Http Rest protocol in Dubbo to support Spring Cloud calling Dubbo services.
   
   
   
   
   # Dubbo Zookeeper 和Spring Cloud zookeeper互联互通方案
   
   # 背景
   
   即使在使用 Http Rest 协议时,Dubbo Zookeeper 和 Spring Cloud Zookeeper 
服务发现模型之间仍然存在不兼容的情况。这是因为 Dubbo 和 Spring Cloud 
在服务注册和发现方面的实现方式和协议设计上存在差异。但是,可以通过以下方式实现它们之间的兼容:
   
   1. 使用相同的注册中心:Dubbo 和 Spring Cloud 应用程序都使用     Zookeeper 作为注册中心,可以通过共享同一个 
Zookeeper 实例来实现服务之间的互联互通。
   2. 使用相同的服务注册协议:可以在     Dubbo 和 Spring Cloud 应用程序中都配置相同的服务注册协议,如 HTTP REST 
协议或 gRPC 协议,以实现服务之间的兼容。
   3. 使用适配器模式:可以编写一个适配器程序,将     Dubbo Zookeeper 服务注册和发现模型转换为 Spring Cloud 
Zookeeper 服务注册和发现模型,或者将 Spring     Cloud Zookeeper 服务注册和发现模型转换为 Dubbo Zookeeper 
服务注册和发现模型。这样,就可以在 Dubbo 和     Spring Cloud 应用程序之间进行兼容性转换。
   
     
   
   # 服务发现模型 
   
   
![service-discovery](https://cn.dubbo.apache.org/imgs/v3/feature/service-discovery/arc2.png)
   
   
   
   
   
   Spring Cloud Zookeeper的服务发现文档:
   
   
https://docs.spring.io/spring-cloud-zookeeper/docs/current/reference/html/#quick-start
   
    
   
   Dubbo的服务发现模型文档:
   
   https://cn.dubbo.apache.org/zh-cn/overview/core-features/service-discovery/
   
    
   
   # 兼容处理
   
   关于服务发现一共需要实现如下位置的兼容
   
   1. 服务提供者上线注册
   2. 服务消费者感知提供者上线
   3. 服务提供者下线销毁
   4. 服务消费者感知提供者下线
   5. 服务消费者获取服务提供者的元数据
   
   
   
   # 使用方式
   
   Dubbo Zookeeper 与 Spring Cloud Zookeeper 都是基于 Zookeeper 
实现的服务发现和注册中心,它们之间的互联互通方案可以通过以下步骤实现:
   
   1. 配置 Dubbo 的注册中心为 Zookeeper,配置 Spring Cloud 的注册中心为 Zookeeper。
   
   2. 在 Dubbo 中暴露服务,使用 `@Service` 注解或 XML 配置文件配置服务接口和实现类,并在 `dubbo:service` 
标签中配置服务的相关信息,如服务名称、版本号、协议、端口等。同时,需要在 `dubbo:protocol` 标签中配置 Http Rest 协议。
   
   3. 在 Spring Cloud 中注册服务,使用 `@EnableDiscoveryClient` 注解开启服务注册和发现功能,使用 
`@RestController` 或 `@RequestMapping` 注解定义 RESTful API 接口,并在接口实现方法中调用 Dubbo 
暴露的服务。
   
   4. 在 Dubbo 中引用服务,使用 `@Reference` 注解或 XML 配置文件配置服务接口和实现类,并在 `dubbo:reference` 
标签中配置服务的相关信息,如服务名称、版本号、协议、负载均衡等。同时,需要在 `dubbo:protocol` 标签中配置 Http Rest 协议。
   
   5. 在 Spring Cloud 中调用服务,使用 `RestTemplate` 或 `FeignClient` 发送 HTTP 请求调用 Dubbo 
引用的服务。
   
   6. 启动 Dubbo 和 Spring Cloud 应用程序,测试服务注册和发现功能是否正常。
   
    
   
   总体来说,Dubbo Zookeeper 与 Spring Cloud Zookeeper 的互联互通方案需要在 Dubbo 和 Spring 
Cloud 应用程序中分别配置服务的注册和发现,以及服务的引用和调用,通过共享 Zookeeper 注册中心实现服务之间的互联互通。同时,需要在 Dubbo 
中配置 Http Rest 协议,以支持 Spring Cloud 调用 Dubbo 服务。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to