銆婂甫鐫€闂鐪嬫簮鐮併€婦ubbo鏈嶅姟娉ㄥ唽
Posted 闃挎彁璇磋
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了銆婂甫鐫€闂鐪嬫簮鐮併€婦ubbo鏈嶅姟娉ㄥ唽相关的知识,希望对你有一定的参考价值。
Dubbo鏄€庝箞涓€涓祦绋嬪皢鏈嶅姟娉ㄥ唽鍒版敞鍐屼腑蹇冪殑鍛紵
Dubbo 閲囩敤鍏?Spring 閰嶇疆鏂瑰紡锛屼細鐩戝惉Spring鏄惁鍚姩瀹屾瘯锛屽惎鍔ㄥ畬鍚庡紑濮嬪垵濮嬪寲Dubbo瀹瑰櫒銆?/p>
馃憞涓嬮潰鏄互Zookeeper涓烘敞鍐屼腑蹇冪殑Dubbo鏈嶅姟娉ㄥ唽鏃跺簭鍥?br class="mq-4">
璐翠竴涓嬩富瑕佺殑鍑犲浠g爜,璇︾粏璇存槑鍙互瑙佸畼鏂规枃妗?/span>
http://dubbo.apache.org/zh-cn/docs/source_code_guide/export-service.html
RegistryProtocol.java
@Override
public <T> Exporter<T> export(final Invoker<T> originInvoker) throws RpcException {
// 鏆撮湶鏈嶅姟
// export invoker
final ExporterChangeableWrapper<T> exporter = doLocalExport(originInvoker);
// 鑾峰緱娉ㄥ唽涓績 URL
URL registryUrl = getRegistryUrl(originInvoker);
// 鑾峰緱娉ㄥ唽涓績瀵硅薄
// registry provider
final Registry registry = getRegistry(originInvoker);
// 鑾峰緱鏈嶅姟鎻愪緵鑰?nbsp;URL
final URL registedProviderUrl = getRegistedProviderUrl(originInvoker);
//to judge to delay publish whether or not
boolean register = registedProviderUrl.getParameter("register", true);
// 鍚戞敞鍐屼腑蹇冭闃呮湇鍔℃秷璐硅€?/span>
ProviderConsumerRegTable.registerProvider(originInvoker, registryUrl, registedProviderUrl);
// 鍚戞敞鍐屼腑蹇冩敞鍐屾湇鍔℃彁渚涜€咃紙鑷繁锛?/span>
if (register) {
register(registryUrl, registedProviderUrl);
ProviderConsumerRegTable.getProviderWrapper(originInvoker).setReg(true); // // 鏍囪鍚戞湰鍦版敞鍐岃〃鐨勬敞鍐屾湇鍔℃彁渚涜€咃紝宸茬粡娉ㄥ唽
}
// 浣跨敤 OverrideListener 瀵硅薄锛岃闃呴厤缃鍒?/span>
// Subscribe the override data
// FIXME When the provider subscribes, it will affect the scene : a certain JVM exposes the service and call the same service. Because the subscribed is cached key with the name of the service, it causes the subscription information to cover.
// 鍒涘缓璁㈤槄閰嶇疆瑙勫垯鐨?nbsp;URL
final URL overrideSubscribeUrl = getSubscribedOverrideUrl(registedProviderUrl);
// 鍒涘缓 OverrideListener 瀵硅薄锛屽苟娣诲姞鍒?nbsp;`overrideListeners` 涓?/span>
final OverrideListener overrideSubscribeListener = new OverrideListener(overrideSubscribeUrl, originInvoker);
overrideListeners.put(overrideSubscribeUrl, overrideSubscribeListener);
// 鍚戞敞鍐屼腑蹇冿紝鍙戣捣璁㈤槄
registry.subscribe(overrideSubscribeUrl, overrideSubscribeListener);
//Ensure that a new exporter instance is returned every time export
return new DestroyableExporter<T>(exporter, originInvoker, overrideSubscribeUrl, registedProviderUrl);
}
protected void doRegister(URL url) {
try {
zkClient.create(toUrlPath(url), url.getParameter(Constants.DYNAMIC_KEY, true));
} catch (Throwable e) {
throw new RpcException("Failed to register " + url + " to zookeeper " + getUrl() + ", cause: " + e.getMessage(), e);
}
}
以上是关于銆婂甫鐫€闂鐪嬫簮鐮併€婦ubbo鏈嶅姟娉ㄥ唽的主要内容,如果未能解决你的问题,请参考以下文章
grpc鏈嶅姟绔浆鎹rotobuf鍒癶ttp璇锋眰鍙傛暟query