Dubbo Zookeeper and Spring Cloud ZooKeeper 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:
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.
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.
Regarding service discovery, it is necessary to achieve compatibility in the following locations
Service provider online registration
Service consumer perception provider online
Service provider offline destruction
Service consumers perceive providers as offline
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:
Configure Dubbo's registry as Zookeeper, and Spring Cloud's registry as Zookeeper.
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.
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.
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.
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 在服务注册和发现方面的实现方式和协议设计上存在差异。但是,可以通过以下方式实现它们之间的兼容:
使用相同的注册中心:Dubbo 和 Spring Cloud 应用程序都使用 Zookeeper 作为注册中心,可以通过共享同一个 Zookeeper 实例来实现服务之间的互联互通。
Dubbo Zookeeper and Spring Cloud ZooKeeper 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:
Service Discovery Model
](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
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:
Dubbo Zookeeper 和Spring Cloud zookeeper互联互通方案
背景
即使在使用 Http Rest 协议时,Dubbo Zookeeper 和 Spring Cloud Zookeeper 服务发现模型之间仍然存在不兼容的情况。这是因为 Dubbo 和 Spring Cloud 在服务注册和发现方面的实现方式和协议设计上存在差异。但是,可以通过以下方式实现它们之间的兼容:
服务发现模型
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/
兼容处理
关于服务发现一共需要实现如下位置的兼容
使用方式
Dubbo Zookeeper 与 Spring Cloud Zookeeper 都是基于 Zookeeper 实现的服务发现和注册中心,它们之间的互联互通方案可以通过以下步骤实现:
配置 Dubbo 的注册中心为 Zookeeper,配置 Spring Cloud 的注册中心为 Zookeeper。
在 Dubbo 中暴露服务,使用
@Service
注解或 XML 配置文件配置服务接口和实现类,并在dubbo:service
标签中配置服务的相关信息,如服务名称、版本号、协议、端口等。同时,需要在dubbo:protocol
标签中配置 Http Rest 协议。在 Spring Cloud 中注册服务,使用
@EnableDiscoveryClient
注解开启服务注册和发现功能,使用@RestController
或@RequestMapping
注解定义 RESTful API 接口,并在接口实现方法中调用 Dubbo 暴露的服务。在 Dubbo 中引用服务,使用
@Reference
注解或 XML 配置文件配置服务接口和实现类,并在dubbo:reference
标签中配置服务的相关信息,如服务名称、版本号、协议、负载均衡等。同时,需要在dubbo:protocol
标签中配置 Http Rest 协议。在 Spring Cloud 中调用服务,使用
RestTemplate
或FeignClient
发送 HTTP 请求调用 Dubbo 引用的服务。启动 Dubbo 和 Spring Cloud 应用程序,测试服务注册和发现功能是否正常。
总体来说,Dubbo Zookeeper 与 Spring Cloud Zookeeper 的互联互通方案需要在 Dubbo 和 Spring Cloud 应用程序中分别配置服务的注册和发现,以及服务的引用和调用,通过共享 Zookeeper 注册中心实现服务之间的互联互通。同时,需要在 Dubbo 中配置 Http Rest 协议,以支持 Spring Cloud 调用 Dubbo 服务。
@ #12243