簡易註冊中心

簡易註冊中心參考手冊

此功能已在 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.dev.org.tw/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd https://dubbo.dev.org.tw/schema /dubbo https://dubbo.dev.org.tw/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)