Skip to content

Commit

Permalink
Service not register to registry if specify register=false
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ committed Jun 22, 2023
1 parent d6776e4 commit 1e109f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ private void doExportUrls(RegisterTypeEnum registerType) {
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()),
() -> {
Expand Down Expand Up @@ -546,6 +547,9 @@ private void doExportUrlsFor1Protocol(ProtocolConfig protocolConfig, List<URL> r

processServiceExecutor(url);

if (CollectionUtils.isEmpty(registryURLs)) {
registerType = RegisterTypeEnum.NEVER_REGISTER;
}
exportUrl(url, registryURLs, registerType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
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;
Expand Down Expand Up @@ -225,7 +226,10 @@ public static List<URL> loadRegistries(AbstractInterfaceConfig interfaceConfig,
.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);
}
}
Expand Down

0 comments on commit 1e109f2

Please sign in to comment.