Dubbo3 組網(wǎng)擴(kuò)展

2022-04-22 11:54 更新

擴(kuò)展說(shuō)明

對(duì)等網(wǎng)絡(luò)節(jié)點(diǎn)組網(wǎng)器。

擴(kuò)展接口

org.apache.dubbo.remoting.p2p.Networker

擴(kuò)展配置

<dubbo:protocol networker="xxx" />
<!-- 缺省值設(shè)置,當(dāng)<dubbo:protocol>沒(méi)有配置networker屬性時(shí),使用此配置 -->
<dubbo:provider networker="xxx" /> 

已知擴(kuò)展

  • org.apache.dubbo.remoting.p2p.support.MulticastNetworker
  • org.apache.dubbo.remoting.p2p.support.FileNetworker

擴(kuò)展示例

Maven 項(xiàng)目結(jié)構(gòu):

src
 |-main
    |-java
        |-com
            |-xxx
                |-XxxNetworker.java (實(shí)現(xiàn)Networker接口)
    |-resources
        |-META-INF
            |-dubbo
                |-org.apache.dubbo.remoting.p2p.Networker (純文本文件,內(nèi)容為:xxx=com.xxx.XxxNetworker)

XxxNetworker.java:

package com.xxx;
 
import org.apache.dubbo.remoting.p2p.Networker;
 
public class XxxNetworker implements Networker {
    public Group lookup(URL url) {
        // ...
    }
}

META-INF/dubbo/org.apache.dubbo.remoting.p2p.Networker:

xxx=com.xxx.XxxNetworker


以上內(nèi)容是否對(duì)您有幫助:
在線(xiàn)筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)