简单注册中心

简单注册中心参考手册

此功能已在 Dubbo 2.7 中移除,请选择其他注册中心进行迁移。

简单注册中心本身就是一个普通的 Dubbo 服务,可以减少第三方依赖,使整体通信方式保持一致。

配置

将简单注册中心暴露为 Dubbo 服务

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="https://dubbo.apache.org/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd https://dubbo.apache.org/schema /dubbo https://dubbo.apache.org/schema/dubbo/dubbo.xsd">
    <!-- Current application information configuration -->
    <dubbo:application name="simple-registry" />
    <!-- Expose service protocol configuration -->
    <dubbo:protocol port="9090" />
    <!-- Expose service configuration -->
    <dubbo:service interface="org.apache.dubbo.registry.RegistryService" ref="registryService" registry="N/A" ondisconnect="disconnect" callbacks="1000">
        <dubbo:method name="subscribe"><dubbo:argument index="1" callback="true" /></dubbo:method>
        <dubbo:method name="unsubscribe"><dubbo:argument index="1" callback="false" /></dubbo:method>
    </dubbo:service>
    <!-- Implementation of a simple registration center, which can be expanded by itself to achieve cluster and state synchronization -->
    <bean id="registryService" class="org.apache.dubbo.registry.simple.SimpleRegistryService" />
</beans>

引用简单注册中心服务

<dubbo:registry address="127.0.0.1:9090" />

或者

<dubbo:service interface="org.apache.dubbo.registry.RegistryService" group="simple" version="1.0.0" ... >

或者

<dubbo:registry address="127.0.0.1:9090" group="simple" version="1.0.0" />

适用性说明

SimpleRegistryService只是一个简单的实现,不支持集群。它可以作为自定义注册中心的参考,但不适合直接在生产环境中使用。


上次修改时间:2023 年 1 月 2 日:增强英文文档 (#1798) (95a9f4f6c1c)