as title 如题
Which Component
spring-cloud-alibaba 2.1.0.RELEASE
Describe the bug
public void initializeMetadata(String serviceName) {
synchronized (monitor) {
if (initializedServices.contains(serviceName)) {
if (logger.isDebugEnabled()) {
logger.debug(
"The metadata of Dubbo service[name : {}] has been initialized",
serviceName);
}
}
else {
if (logger.isInfoEnabled()) {
logger.info(
"The metadata of Dubbo service[name : {}] is about to be initialized",
serviceName);
}
// Keep the order in following invocations
initSubscribedDubboMetadataService(serviceName);
initDubboRestServiceMetadataRepository(serviceName);
// mark this service name having been initialized
initializedServices.add(serviceName);
}
}
}
protected void initSubscribedDubboMetadataService(String serviceName) {
discoveryClient.getInstances(serviceName).stream().findAny()
.map(this::getDubboMetadataServiceURLs)
.ifPresent(dubboMetadataServiceURLs -> {
dubboMetadataServiceURLs.forEach(dubboMetadataServiceURL -> {
try {
initSubscribedDubboMetadataServiceURL(
dubboMetadataServiceURL);
initDubboMetadataServiceProxy(dubboMetadataServiceURL);
}
catch (Throwable e) {
if (logger.isErrorEnabled()) {
logger.error(e.getMessage(), e);
}
}
});
});
}
The initializedServices.add(serviceName);
should be added after successful initialization proxy
Additional context
Java8 、 Version 2.1.0.RELEASE
4条答案
按热度按时间bt1cpqcv1#
That's a good suggestion.
fxnxkyjh2#
Does this mean that we should check
code is true, if it's not, we should execute
???
envsm3lx3#
是的,我也发现了这个问题,如果所订阅的生产者后启动的话,会导致永远无法初始化生产者的元数据和服务订阅。
ulmd4ohb4#
telnet result
success:
PROVIDER:
cloudx-trade/com.alibaba.cloud.dubbo.service.DubboMetadataService:1.0.0
CONSUMER:
com.xxx.cms.api.service.ArticleService
cloudx-cms/com.alibaba.cloud.dubbo.service.DubboMetadataService:1.0.0
failure:
PROVIDER:
cloudx-trade/com.alibaba.cloud.dubbo.service.DubboMetadataService:1.0.0
CONSUMER:
com.xxx.cms.api.service.ArticleService