Fix service discovery delay subscription

This commit is contained in:
ken.lj 2020-09-17 17:56:52 +08:00
parent b1cf4f0dd4
commit 4808d7bff3
4 changed files with 8 additions and 4 deletions

View File

@ -159,7 +159,7 @@ public class Environment extends LifecycleAdapter implements FrameworkExt {
public Configuration getDynamicGlobalConfiguration() {
if (dynamicGlobalConfiguration == null) {
if (dynamicConfiguration != null) {
if (dynamicConfiguration == null) {
throw new IllegalStateException("Init dynamic configuration before use.");
}
dynamicGlobalConfiguration = new CompositeConfiguration();

View File

@ -23,12 +23,11 @@
<dubbo:application name="demo-consumer">
<dubbo:parameter key="mapping-type" value="metadata"/>
<dubbo:parameter key="enable-auto-migration" value="true"/>
</dubbo:application>
<!-- <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>-->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service"/>
<dubbo:reference id="demoService" check="false"
interface="org.apache.dubbo.demo.DemoService"/>

View File

@ -267,6 +267,7 @@ public class ServiceDiscoveryRegistry implements Registry {
if (check) {
throw new IllegalStateException("Should has at least one way to know which services this interface belongs to, subscription url: " + url);
}
return;
}
subscribeURLs(url, listener, serviceNames);

View File

@ -17,6 +17,8 @@
package org.apache.dubbo.registry.client.migration;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.registry.integration.RegistryProtocol;
import org.apache.dubbo.rpc.Invocation;
@ -26,6 +28,7 @@ import org.apache.dubbo.rpc.cluster.Cluster;
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
public class ServiceDiscoveryMigrationInvoker<T> extends MigrationInvoker<T> {
private static final Logger logger = LoggerFactory.getLogger(ServiceDiscoveryMigrationInvoker.class);
public ServiceDiscoveryMigrationInvoker(RegistryProtocol registryProtocol, Cluster cluster, Registry registry, Class<T> type, URL url, URL consumerUrl) {
super(registryProtocol, cluster, registry, type, url, consumerUrl);
@ -38,7 +41,8 @@ public class ServiceDiscoveryMigrationInvoker<T> extends MigrationInvoker<T> {
@Override
public synchronized void fallbackToInterfaceInvoker() {
destroyServiceDiscoveryInvoker(this.getServiceDiscoveryInvoker());
logger.error("Service discovery registry type does not support discovery of interface level addresses, " + getRegistryUrl());
migrateToServiceDiscoveryInvoker(true);
}
@Override