1. 程式人生 > >Dubbo系列之 (六)服務訂閱(3)

Dubbo系列之 (六)服務訂閱(3)

# 輔助連結 ## [Dubbo系列之 (一)SPI擴充套件 ](https://www.cnblogs.com/liferecord/p/13445631.html) ## [Dubbo系列之 (二)Registry註冊中心-註冊(1)](https://www.cnblogs.com/liferecord/p/13462175.html) ## [Dubbo系列之 (三)Registry註冊中心-註冊(2)](https://www.cnblogs.com/liferecord/p/13497411.html) ## [Dubbo系列之 (四)服務訂閱(1)](https://www.cnblogs.com/liferecord/p/13524747.html) ## [Dubbo系列之 (五)服務訂閱(2)](https://www.cnblogs.com/liferecord/p/13540399.html) ## [Dubbo系列之 (六)服務訂閱(3)](https://www.cnblogs.com/liferecord/p/13637885.html) # RegistryDirectory 當RegistryDirectory#substribe()方法被RegistryProtocol#refer()方法呼叫時,本地服務消費端會與註冊中心互動,拉取最新的服務提供者,並與這些服務提供者建立TCP連線。 ``` public void subscribe(URL url) { setConsumerUrl(url); CONSUMER_CONFIGURATION_LISTENER.addNotifyListener(this); serviceConfigurationListener = new ReferenceConfigurationListener(this, url); registry.subscribe(url, this); } ``` 從上面的程式碼塊可以知道RegistryDirectory直接呼叫的註冊中心的substribe()方法。我們以ZookeeperRegistry為例,檢視其方法doSubscribe()。 ``` public void doSubscribe(final URL url, final NotifyListener listener) { ...... } else { // 正常服務訂閱