Service not register to registry if specify register=false (#12584)
This commit is contained in:
parent
d6776e4008
commit
cf2a63580e
|
|
@ -512,7 +512,8 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
|
|||
providerModel.setDestroyRunner(getDestroyRunner());
|
||||
repository.registerProvider(providerModel);
|
||||
|
||||
List<URL> registryURLs = ConfigValidationUtils.loadRegistries(this, true);
|
||||
List<URL> registryURLs = !Boolean.FALSE.equals(isRegister()) ?
|
||||
ConfigValidationUtils.loadRegistries(this, true) : Collections.emptyList();
|
||||
|
||||
MetricsEventBus.post(RegistryEvent.toRsEvent(module.getApplicationModel(), getUniqueServiceName(), protocols.size() * registryURLs.size()),
|
||||
() -> {
|
||||
|
|
@ -546,6 +547,9 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
|
|||
|
||||
processServiceExecutor(url);
|
||||
|
||||
if (CollectionUtils.isEmpty(registryURLs)) {
|
||||
registerType = RegisterTypeEnum.NEVER_REGISTER;
|
||||
}
|
||||
exportUrl(url, registryURLs, registerType);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ import static org.apache.dubbo.config.Constants.LAYER_KEY;
|
|||
import static org.apache.dubbo.config.Constants.NAME;
|
||||
import static org.apache.dubbo.config.Constants.ORGANIZATION;
|
||||
import static org.apache.dubbo.config.Constants.OWNER;
|
||||
import static org.apache.dubbo.config.Constants.REGISTER_KEY;
|
||||
import static org.apache.dubbo.config.Constants.STATUS_KEY;
|
||||
import static org.apache.dubbo.monitor.Constants.LOGSTAT_PROTOCOL;
|
||||
import static org.apache.dubbo.registry.Constants.REGISTER_IP_KEY;
|
||||
|
|
@ -225,7 +226,10 @@ public class ConfigValidationUtils {
|
|||
.setScopeModel(interfaceConfig.getScopeModel())
|
||||
.build();
|
||||
// provider delay register state will be checked in RegistryProtocol#export
|
||||
if (provider || url.getParameter(SUBSCRIBE_KEY, true)) {
|
||||
if (provider && url.getParameter(REGISTER_KEY, true)) {
|
||||
registryList.add(url);
|
||||
}
|
||||
if (!provider && url.getParameter(SUBSCRIBE_KEY, true)) {
|
||||
registryList.add(url);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue