1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

Merge pull request #11 from alibaba/master

update
This commit is contained in:
yuhuangbin 2020-03-20 15:38:03 +08:00 committed by GitHub
commit a636666a20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 17 deletions

View File

@ -51,6 +51,8 @@ public class NacosConfigEndpointAutoConfiguration {
} }
@Bean @Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "spring.cloud.nacos.config.health.enabled", matchIfMissing = true)
public NacosConfigHealthIndicator nacosConfigHealthIndicator() { public NacosConfigHealthIndicator nacosConfigHealthIndicator() {
return new NacosConfigHealthIndicator(nacosConfigManager.getConfigService()); return new NacosConfigHealthIndicator(nacosConfigManager.getConfigService());
} }

View File

@ -40,7 +40,6 @@
"type": "java.util.List", "type": "java.util.List",
"description": "a set of shared configurations .e.g: spring.cloud.nacos.config.shared-configs[0]=xxx ." "description": "a set of shared configurations .e.g: spring.cloud.nacos.config.shared-configs[0]=xxx ."
}, },
{ {
"name": "spring.cloud.nacos.config.refreshable-dataids", "name": "spring.cloud.nacos.config.refreshable-dataids",
"type": "java.lang.String", "type": "java.lang.String",
@ -56,6 +55,12 @@
"type": "java.util.List", "type": "java.util.List",
"description": "a set of extensional configurations .e.g: spring.cloud.nacos.config.extension-configs[0]=xxx ." "description": "a set of extensional configurations .e.g: spring.cloud.nacos.config.extension-configs[0]=xxx ."
}, },
{
"name": "spring.cloud.nacos.config.health.enabled",
"type": "java.lang.Boolean",
"defaultValue": true,
"description": "the switch for health check, it default enabled(true)."
},
{ {
"name": "spring.cloud.nacos.config.refresh-enabled", "name": "spring.cloud.nacos.config.refresh-enabled",
"type": "java.lang.Boolean", "type": "java.lang.Boolean",

View File

@ -222,10 +222,15 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
Collection<ServiceInstance> serviceInstances = serviceInstancesFunction Collection<ServiceInstance> serviceInstances = serviceInstancesFunction
.apply(serviceName); .apply(serviceName);
// issue : ReStarting a consumer and then starting a provider does not automatically discover the registration
// fix https://github.com/alibaba/spring-cloud-alibaba/issues/753
// Re-obtain the latest list of available metadata address here, ip or port may change.
// by https://github.com/wangzihaogithub
dubboMetadataConfigServiceProxy.removeProxy(serviceName);
repository.removeMetadataAndInitializedService(serviceName);
dubboGenericServiceFactory.destroy(serviceName);
repository.initializeMetadata(serviceName);
if (CollectionUtils.isEmpty(serviceInstances)) { if (CollectionUtils.isEmpty(serviceInstances)) {
dubboMetadataConfigServiceProxy.removeProxy(serviceName);
repository.removeMetadataAndInitializedService(serviceName);
dubboGenericServiceFactory.destroy(serviceName);
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
logger.warn( logger.warn(
"There is no instance from service[name : {}], and then Dubbo Service[key : {}] will not be " "There is no instance from service[name : {}], and then Dubbo Service[key : {}] will not be "
@ -246,18 +251,6 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
DubboMetadataService dubboMetadataService = dubboMetadataConfigServiceProxy DubboMetadataService dubboMetadataService = dubboMetadataConfigServiceProxy
.getProxy(serviceName); .getProxy(serviceName);
if (dubboMetadataService == null) { // If not found, try to initialize
if (logger.isInfoEnabled()) {
logger.info(
"The metadata of Dubbo service[key : {}] can't be found when the subscribed service[name : {}], "
+ "and then try to initialize it",
url.getServiceKey(), serviceName);
}
repository.initializeMetadata(serviceName);
dubboMetadataService = dubboMetadataConfigServiceProxy.getProxy(serviceName);
}
if (dubboMetadataService == null) { // It makes sure not-found, return immediately if (dubboMetadataService == null) { // It makes sure not-found, return immediately
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
logger.warn( logger.warn(
@ -269,7 +262,6 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
} }
List<URL> exportedURLs = getExportedURLs(dubboMetadataService, url); List<URL> exportedURLs = getExportedURLs(dubboMetadataService, url);
for (URL exportedURL : exportedURLs) { for (URL exportedURL : exportedURLs) {
String protocol = exportedURL.getProtocol(); String protocol = exportedURL.getProtocol();
List<URL> subscribedURLs = new LinkedList<>(); List<URL> subscribedURLs = new LinkedList<>();