From fd410ccf38c0d8fc0170931a3275e1f6c9a1003a Mon Sep 17 00:00:00 2001 From: mercyblitz Date: Wed, 3 Apr 2019 13:55:06 +0800 Subject: [PATCH] Polish spring-cloud-incubator/spring-cloud-alibaba#524 : Add @ConfigurationProperties for Dubbo Spring Cloud --- .../DubboServiceAutoConfiguration.java | 3 + ...oServiceRegistrationAutoConfiguration.java | 2 +- .../dubbo/env/DubboCloudProperties.java | 81 ++++++++++ ...ebApplicationEnvironmentPostProcessor.java | 2 +- .../DubboServiceMetadataRepository.java | 139 +++++++++++++++++- .../dubbo/registry/SpringCloudRegistry.java | 88 +---------- .../registry/SpringCloudRegistryFactory.java | 3 +- .../main/resources/META-INF/spring.factories | 16 +- .../src/main/resources/application.yaml | 8 +- 9 files changed, 238 insertions(+), 104 deletions(-) create mode 100644 spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/env/DubboCloudProperties.java rename spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/{registry => }/env/DubboNonWebApplicationEnvironmentPostProcessor.java (99%) diff --git a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/autoconfigure/DubboServiceAutoConfiguration.java b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/autoconfigure/DubboServiceAutoConfiguration.java index c4abb94ef..56e9e8902 100644 --- a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/autoconfigure/DubboServiceAutoConfiguration.java +++ b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/autoconfigure/DubboServiceAutoConfiguration.java @@ -20,7 +20,9 @@ import org.apache.dubbo.common.utils.Assert; import org.apache.dubbo.config.spring.util.PropertySourcesUtils; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.source.ConfigurationPropertySources; +import org.springframework.cloud.alibaba.dubbo.env.DubboCloudProperties; import org.springframework.cloud.alibaba.dubbo.service.DubboGenericServiceExecutionContextFactory; import org.springframework.cloud.alibaba.dubbo.service.DubboGenericServiceFactory; import org.springframework.cloud.alibaba.dubbo.service.parameter.PathVariableServiceParameterResolver; @@ -49,6 +51,7 @@ import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_SCAN_PREFIX; * @author Mercy */ @Configuration +@EnableConfigurationProperties(DubboCloudProperties.class) public class DubboServiceAutoConfiguration { @Bean diff --git a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/autoconfigure/DubboServiceRegistrationAutoConfiguration.java b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/autoconfigure/DubboServiceRegistrationAutoConfiguration.java index 081e5b6e8..4ca3246e9 100644 --- a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/autoconfigure/DubboServiceRegistrationAutoConfiguration.java +++ b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/autoconfigure/DubboServiceRegistrationAutoConfiguration.java @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import static org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceRegistrationAutoConfiguration.CONSUL_AUTO_CONFIGURATION_CLASS_NAME; import static org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceRegistrationAutoConfiguration.EUREKA_AUTO_CONFIGURATION_CLASS_NAME; -import static org.springframework.cloud.alibaba.dubbo.registry.SpringCloudRegistry.DUBBO_URLS_METADATA_PROPERTY_NAME; +import static org.springframework.cloud.alibaba.dubbo.metadata.repository.DubboServiceMetadataRepository.DUBBO_URLS_METADATA_PROPERTY_NAME; import static org.springframework.util.ObjectUtils.isEmpty; /** diff --git a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/env/DubboCloudProperties.java b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/env/DubboCloudProperties.java new file mode 100644 index 000000000..bb4d38648 --- /dev/null +++ b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/env/DubboCloudProperties.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.cloud.alibaba.dubbo.env; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import static org.springframework.util.StringUtils.commaDelimitedListToStringArray; +import static org.springframework.util.StringUtils.hasText; +import static org.springframework.util.StringUtils.trimAllWhitespace; + +/** + * Dubbo Cloud {@link ConfigurationProperties Properties} + * + * @author Mercy + */ +@ConfigurationProperties(prefix = "dubbo.cloud") +public class DubboCloudProperties { + + /** + * All services of Dubbo + */ + public static final String ALL_DUBBO_SERVICES = "*"; + + /** + * The subscribed services, the default value is "*". The multiple value will use comma(",") as the separator. + * + * @see #ALL_DUBBO_SERVICES + */ + private String subscribedServices = ALL_DUBBO_SERVICES; + + public String getSubscribedServices() { + return subscribedServices; + } + + public void setSubscribedServices(String subscribedServices) { + this.subscribedServices = subscribedServices; + } + + /** + * Get the subscribed services as a {@link Set} with configuration order. + * + * @return non-null Read-only {@link Set} + */ + public Set subscribedServices() { + + String[] services = commaDelimitedListToStringArray(getSubscribedServices()); + + if (services.length < 1) { + return Collections.emptySet(); + } + + Set subscribedServices = new LinkedHashSet<>(); + + for (String service : services) { + if (hasText(service)) { // filter blank service name + // remove all whitespace + subscribedServices.add(trimAllWhitespace(service)); + } + } + + return Collections.unmodifiableSet(subscribedServices); + } +} diff --git a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/env/DubboNonWebApplicationEnvironmentPostProcessor.java b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/env/DubboNonWebApplicationEnvironmentPostProcessor.java similarity index 99% rename from spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/env/DubboNonWebApplicationEnvironmentPostProcessor.java rename to spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/env/DubboNonWebApplicationEnvironmentPostProcessor.java index ef72fbf0e..5d63860ec 100644 --- a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/env/DubboNonWebApplicationEnvironmentPostProcessor.java +++ b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/env/DubboNonWebApplicationEnvironmentPostProcessor.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cloud.alibaba.dubbo.registry.env; +package org.springframework.cloud.alibaba.dubbo.env; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/metadata/repository/DubboServiceMetadataRepository.java b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/metadata/repository/DubboServiceMetadataRepository.java index e4a581027..53f86893b 100644 --- a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/metadata/repository/DubboServiceMetadataRepository.java +++ b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/metadata/repository/DubboServiceMetadataRepository.java @@ -23,22 +23,35 @@ import com.fasterxml.jackson.databind.type.TypeFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.alibaba.dubbo.env.DubboCloudProperties; import org.springframework.cloud.alibaba.dubbo.http.matcher.RequestMetadataMatcher; import org.springframework.cloud.alibaba.dubbo.metadata.DubboRestServiceMetadata; import org.springframework.cloud.alibaba.dubbo.metadata.RequestMetadata; import org.springframework.cloud.alibaba.dubbo.metadata.ServiceRestMetadata; import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigService; import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigServiceProxy; +import org.springframework.cloud.alibaba.dubbo.util.JSONUtils; +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.http.HttpRequest; import org.springframework.stereotype.Repository; +import org.springframework.util.CollectionUtils; +import javax.annotation.PostConstruct; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; +import static org.apache.dubbo.common.Constants.APPLICATION_KEY; +import static org.springframework.cloud.alibaba.dubbo.env.DubboCloudProperties.ALL_DUBBO_SERVICES; import static org.springframework.cloud.alibaba.dubbo.http.DefaultHttpRequest.builder; import static org.springframework.util.CollectionUtils.isEmpty; @@ -50,21 +63,80 @@ import static org.springframework.util.CollectionUtils.isEmpty; @Repository public class DubboServiceMetadataRepository { + /** + * The property name of Dubbo {@link URL URLs} metadata + */ + public static final String DUBBO_URLS_METADATA_PROPERTY_NAME = "dubbo.urls"; + private final Logger logger = LoggerFactory.getLogger(getClass()); private final ObjectMapper objectMapper = new ObjectMapper(); private final Set registeredURLs = new LinkedHashSet<>(); + private final Map dubboServiceKeysRepository = new HashMap<>(); + /** * Key is application name * Value is Map */ - private Map> repository = newHashMap(); + private Map> dubboRestServiceMetadataRepository = newHashMap(); + + private Set subscribedServices; + + @Autowired + private DubboCloudProperties dubboCloudProperties; @Autowired private DubboMetadataConfigServiceProxy dubboMetadataConfigServiceProxy; + @Autowired + private DiscoveryClient discoveryClient; + + @Autowired + private JSONUtils jsonUtils; + + @Value("${spring.application.name}") + private String currentApplicationName; + + @PostConstruct + public void init() { + initSubscribedServices(); + initDubboServiceKeysRepository(); + retainAvailableSubscribedServices(); + initDubboRestServiceMetadataRepository(); + } + + /** + * The specified service is subscribe or not + * + * @param serviceName the service name + * @return + */ + public boolean isSubscribedService(String serviceName) { + return subscribedServices.contains(serviceName); + } + + /** + * Get the service name by the {@link URL#getServiceKey() service key} + * + * @param url {@link URL} + * @return the service name if found + */ + public String getServiceName(URL url) { + return getServiceName(url.getServiceKey()); + } + + /** + * Get the service name by the {@link URL#getServiceKey() service key} + * + * @param serviceKey the {@link URL#getServiceKey() service key} + * @return the service name if found + */ + public String getServiceName(String serviceKey) { + return dubboServiceKeysRepository.get(serviceKey); + } + public void registerURL(URL url) { this.registeredURLs.add(url); } @@ -77,6 +149,19 @@ public class DubboServiceMetadataRepository { return Collections.unmodifiableSet(registeredURLs); } + /** + * Build the {@link URL urls} by the specified {@link ServiceInstance} + * + * @param serviceInstance {@link ServiceInstance} + * @return the mutable {@link URL urls} + */ + public List buildURLs(ServiceInstance serviceInstance) { + Map metadata = serviceInstance.getMetadata(); + String dubboURLsJSON = metadata.get(DUBBO_URLS_METADATA_PROPERTY_NAME); + List urlValues = jsonUtils.toList(dubboURLsJSON); + return urlValues.stream().map(URL::valueOf).collect(Collectors.toList()); + } + /** * Initialize the specified service's {@link ServiceRestMetadata} * @@ -84,7 +169,7 @@ public class DubboServiceMetadataRepository { */ public void initialize(String serviceName) { - if (repository.containsKey(serviceName)) { + if (dubboRestServiceMetadataRepository.containsKey(serviceName)) { return; } @@ -123,7 +208,7 @@ public class DubboServiceMetadataRepository { * @return {@link DubboRestServiceMetadata} if matched, or null */ public DubboRestServiceMetadata get(String serviceName, RequestMetadata requestMetadata) { - return match(repository, serviceName, requestMetadata); + return match(dubboRestServiceMetadataRepository, serviceName, requestMetadata); } private T match(Map> repository, String serviceName, @@ -166,22 +251,21 @@ public class DubboServiceMetadataRepository { } private Map getMetadataMap(String serviceName) { - return getMap(repository, serviceName); + return getMap(dubboRestServiceMetadataRepository, serviceName); } private Set getServiceRestMetadataSet(String serviceName) { DubboMetadataConfigService dubboMetadataConfigService = dubboMetadataConfigServiceProxy.newProxy(serviceName); - String serviceRestMetadataJsonConfig = dubboMetadataConfigService.getServiceRestMetadata(); - Set metadata; + Set metadata = Collections.emptySet(); try { + String serviceRestMetadataJsonConfig = dubboMetadataConfigService.getServiceRestMetadata(); metadata = objectMapper.readValue(serviceRestMetadataJsonConfig, TypeFactory.defaultInstance().constructCollectionType(LinkedHashSet.class, ServiceRestMetadata.class)); } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error(e.getMessage(), e); } - metadata = Collections.emptySet(); } return metadata; } @@ -203,4 +287,45 @@ public class DubboServiceMetadataRepository { return new LinkedHashMap<>(); } + private void initSubscribedServices() { + // If subscribes all services + if (ALL_DUBBO_SERVICES.equalsIgnoreCase(dubboCloudProperties.getSubscribedServices())) { + subscribedServices = new HashSet<>(discoveryClient.getServices()); + } else { + subscribedServices = new HashSet<>(dubboCloudProperties.subscribedServices()); + } + + excludeSelf(subscribedServices); + } + + private void excludeSelf(Set subscribedServices) { + subscribedServices.remove(currentApplicationName); + } + + private void initDubboServiceKeysRepository() { + subscribedServices.stream() + .map(discoveryClient::getInstances) + .filter(this::isNotEmpty) + .forEach(serviceInstances -> { + ServiceInstance serviceInstance = serviceInstances.get(0); + buildURLs(serviceInstance).forEach(url -> { + String serviceKey = url.getServiceKey(); + String serviceName = url.getParameter(APPLICATION_KEY); + dubboServiceKeysRepository.put(serviceKey, serviceName); + }); + }); + } + + private void retainAvailableSubscribedServices() { + // dubboServiceKeysRepository.values() returns the available services(possible duplicated ones) + subscribedServices = new HashSet<>(dubboServiceKeysRepository.values()); + } + + private void initDubboRestServiceMetadataRepository() { + subscribedServices.forEach(this::initialize); + } + + private boolean isNotEmpty(Collection collection) { + return !CollectionUtils.isEmpty(collection); + } } diff --git a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/SpringCloudRegistry.java b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/SpringCloudRegistry.java index 86f24ab48..24db73660 100644 --- a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/SpringCloudRegistry.java +++ b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/SpringCloudRegistry.java @@ -21,25 +21,13 @@ import org.apache.dubbo.registry.NotifyListener; import org.apache.dubbo.registry.RegistryFactory; import org.springframework.cloud.alibaba.dubbo.metadata.repository.DubboServiceMetadataRepository; -import org.springframework.cloud.alibaba.dubbo.util.JSONUtils; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; -import java.util.Collection; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Set; import java.util.concurrent.ScheduledExecutorService; import java.util.stream.Collectors; -import static java.util.Collections.emptyMap; -import static org.apache.dubbo.common.Constants.APPLICATION_KEY; -import static org.springframework.util.CollectionUtils.isEmpty; - /** * Dubbo {@link RegistryFactory} uses Spring Cloud Service Registration abstraction, whose protocol is "spring-cloud" * @@ -47,79 +35,13 @@ import static org.springframework.util.CollectionUtils.isEmpty; */ public class SpringCloudRegistry extends AbstractSpringCloudRegistry { - /** - * The property name of Dubbo {@link URL URLs} metadata - */ - public static final String DUBBO_URLS_METADATA_PROPERTY_NAME = "dubbo.urls"; - - /** - * The parameter name of the services of Dubbo Provider - */ - public static final String DUBBO_PROVIDER_SERVICES_PARAM_NAME = "dubbo-provider-services"; - - /** - * All services of Dubbo Provider - */ - public static final String ALL_DUBBO_PROVIDER_SERVICES = "*"; - private final DubboServiceMetadataRepository dubboServiceMetadataRepository; - private final JSONUtils jsonUtils; - - private final Set dubboProviderServices; - - private final Map dubboServiceKeysCache; - public SpringCloudRegistry(URL url, DiscoveryClient discoveryClient, ScheduledExecutorService servicesLookupScheduler, - DubboServiceMetadataRepository dubboServiceMetadataRepository, - ConfigurableApplicationContext applicationContext) { + DubboServiceMetadataRepository dubboServiceMetadataRepository) { super(url, discoveryClient, servicesLookupScheduler); this.dubboServiceMetadataRepository = dubboServiceMetadataRepository; - this.jsonUtils = applicationContext.getBean(JSONUtils.class); - this.dubboProviderServices = getDubboProviderServices(); - this.dubboServiceKeysCache = this.initDubboServiceKeysCache(); - } - - private Map initDubboServiceKeysCache() { - - if (isEmpty(dubboProviderServices)) { - return emptyMap(); - } - - Map newCache = new HashMap<>(); - - dubboProviderServices.stream() - .map(this::getServiceInstances) - .filter(this::isNotEmpty) - .forEach(serviceInstances -> { - ServiceInstance serviceInstance = serviceInstances.get(0); - getURLs(serviceInstance).forEach(url -> { - String serviceKey = url.getServiceKey(); - String serviceName = url.getParameter(APPLICATION_KEY); - newCache.put(serviceKey, serviceName); - }); - }); - - return newCache; - } - - private boolean isNotEmpty(Collection collection) { - return !CollectionUtils.isEmpty(collection); - } - - private List getURLs(ServiceInstance serviceInstance) { - Map metadata = serviceInstance.getMetadata(); - String dubboURLsJSON = metadata.get(DUBBO_URLS_METADATA_PROPERTY_NAME); - List urlValues = jsonUtils.toList(dubboURLsJSON); - return urlValues.stream().map(URL::valueOf).collect(Collectors.toList()); - } - - private Set getDubboProviderServices() { - URL registryURL = getUrl(); - String services = registryURL.getParameter(DUBBO_PROVIDER_SERVICES_PARAM_NAME, ALL_DUBBO_PROVIDER_SERVICES); - return ALL_DUBBO_PROVIDER_SERVICES.equalsIgnoreCase(services) ? - getAllServiceNames() : StringUtils.commaDelimitedListToSet(services); } @Override @@ -134,18 +56,18 @@ public class SpringCloudRegistry extends AbstractSpringCloudRegistry { @Override protected boolean supports(String serviceName) { - return dubboProviderServices.contains(serviceName); + return dubboServiceMetadataRepository.isSubscribedService(serviceName); } @Override protected String getServiceName(URL url) { - String serviceKey = url.getServiceKey(); - return dubboServiceKeysCache.get(serviceKey); + return dubboServiceMetadataRepository.getServiceName(url); } @Override protected void notifySubscriber(URL url, NotifyListener listener, List serviceInstances) { - List urls = serviceInstances.stream().map(this::getURLs) + List urls = serviceInstances.stream() + .map(dubboServiceMetadataRepository::buildURLs) .flatMap(List::stream) .collect(Collectors.toList()); notify(url, listener, urls); diff --git a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/SpringCloudRegistryFactory.java b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/SpringCloudRegistryFactory.java index 15dd3e5d4..4a0468015 100644 --- a/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/SpringCloudRegistryFactory.java +++ b/spring-cloud-alibaba-dubbo/src/main/java/org/springframework/cloud/alibaba/dubbo/registry/SpringCloudRegistryFactory.java @@ -68,8 +68,7 @@ public class SpringCloudRegistryFactory implements RegistryFactory { @Override public Registry getRegistry(URL url) { init(); - return new SpringCloudRegistry(url, discoveryClient, servicesLookupScheduler, - dubboServiceMetadataRepository, applicationContext); + return new SpringCloudRegistry(url, discoveryClient, servicesLookupScheduler, dubboServiceMetadataRepository); } public static void setApplicationContext(ConfigurableApplicationContext applicationContext) { diff --git a/spring-cloud-alibaba-dubbo/src/main/resources/META-INF/spring.factories b/spring-cloud-alibaba-dubbo/src/main/resources/META-INF/spring.factories index 515af6f50..46ad69593 100644 --- a/spring-cloud-alibaba-dubbo/src/main/resources/META-INF/spring.factories +++ b/spring-cloud-alibaba-dubbo/src/main/resources/META-INF/spring.factories @@ -1,15 +1,15 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboMetadataAutoConfiguration,\ - org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboOpenFeignAutoConfiguration,\ - org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceRegistrationAutoConfiguration,\ - org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceRegistrationNonWebApplicationAutoConfiguration,\ - org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboLoadBalancedRestTemplateAutoConfiguration,\ - org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceAutoConfiguration +org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboMetadataAutoConfiguration,\ +org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboOpenFeignAutoConfiguration,\ +org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceRegistrationAutoConfiguration,\ +org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceRegistrationNonWebApplicationAutoConfiguration,\ +org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboLoadBalancedRestTemplateAutoConfiguration,\ +org.springframework.cloud.alibaba.dubbo.autoconfigure.DubboServiceAutoConfiguration org.springframework.context.ApplicationContextInitializer=\ - org.springframework.cloud.alibaba.dubbo.context.DubboServiceRegistrationApplicationContextInitializer +org.springframework.cloud.alibaba.dubbo.context.DubboServiceRegistrationApplicationContextInitializer org.springframework.boot.env.EnvironmentPostProcessor=\ -org.springframework.cloud.alibaba.dubbo.registry.env.DubboNonWebApplicationEnvironmentPostProcessor \ No newline at end of file +org.springframework.cloud.alibaba.dubbo.env.DubboNonWebApplicationEnvironmentPostProcessor \ No newline at end of file diff --git a/spring-cloud-alibaba-examples/spring-cloud-alibaba-dubbo-examples/spring-cloud-dubbo-consumer-sample/src/main/resources/application.yaml b/spring-cloud-alibaba-examples/spring-cloud-alibaba-dubbo-examples/spring-cloud-dubbo-consumer-sample/src/main/resources/application.yaml index 50211ae2c..7244e4512 100644 --- a/spring-cloud-alibaba-examples/spring-cloud-alibaba-dubbo-examples/spring-cloud-dubbo-consumer-sample/src/main/resources/application.yaml +++ b/spring-cloud-alibaba-examples/spring-cloud-alibaba-dubbo-examples/spring-cloud-dubbo-consumer-sample/src/main/resources/application.yaml @@ -3,9 +3,13 @@ dubbo: # The Spring Cloud Dubbo's registry extension ## the default value of dubbo-provider-services is "*", that means to subscribe all providers, ## thus it's optimized if subscriber specifies the required providers. - address: spring-cloud://localhost?dubbo-provider-services=${provider.application.name} -# The traditional Dubbo's registry + address: spring-cloud://localhost +# The traditional Dubbo's registry also is supported # address: zookeeper://127.0.0.1:2181 + cloud: + # The subscribed services in consumer side + subscribed-services: ${provider.application.name} + server: port: 0