-
Notifications
You must be signed in to change notification settings - Fork 26.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] random port -1 is not effect #14569
Comments
I'll try to fix it |
I think this is by design, and this random means not picking a random one, but looking for an available port starting from the default port upwards, see: DUBBO-501 随机端口改为在缺省端口的基础上增长: |
getAvailablePort is ok In this scenario, when multiple Models are created for data isolation, the port data cannot be isolated and only takes effect once. public class ModelDemo {
private static final Logger logger = LoggerFactory.getLogger(ModelDemo.class);
public static void main(String[] args) throws InterruptedException {
start(new FrameworkModel(), -1);
logger.info("frameworkModelOne start success");
start(new FrameworkModel(), -1);
new CountDownLatch(1).await();
}
private static void start(FrameworkModel frameworkModel, int port) {
//创建订单子系统应用级ApplicationModel
ApplicationModel orderApplicationModel = frameworkModel.newApplication();
//创建模块级ModuleModel
ModuleModel moduleModel = orderApplicationModel.newModule();
//Model的配置管理通过对应的ConfigManager进行
ConfigManager appConfigManager = orderApplicationModel.getApplicationConfigManager();
//应用配置
ApplicationConfig application = new ApplicationConfig("dubbo-provider-app");
//关闭QOS避免端口冲突
application.setQosEnable(false);
appConfigManager.setApplication(application);
//应用层级的配置中心、元数据中心、协议默认设置
appConfigManager.addRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
appConfigManager.addMetadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"));
appConfigManager.addProtocol(new ProtocolConfig(CommonConstants.DUBBO, port));
//配置模块
ModuleConfigManager moduleConfigManager = moduleModel.getConfigManager();
moduleConfigManager.setModule(new ModuleConfig("dubbo-provider-app-module"));
ServiceConfig<OrderService> serviceConfig = new ServiceConfig<>();
//设置该ServiceConfig对应的ModuleModel
serviceConfig.setScopeModel(moduleModel);
serviceConfig.setInterface(OrderService.class);
serviceConfig.setRef(new OrderServiceImpl());
//为ModuleModel添加ServiceConfig
moduleConfigManager.addConfig(serviceConfig);
//导出服务
serviceConfig.export();
}
} |
@songxiaosheng |
agree, consider change method name from |
Pre-check
Search before asking
Apache Dubbo Component
Java SDK (apache/dubbo)
Dubbo Version
3.3.0-beta.4
Steps to reproduce this issue
when i use port -1 ,it use a defaultPort 20880
ProtocolConfig protocolConfig = new ProtocolConfig(CommonConstants.DUBBO, -1);
What you expected to happen
when i use port -1 ,i want it use a port random
Anything else
No response
Are you willing to submit a pull request to fix on your own?
Code of Conduct
The text was updated successfully, but these errors were encountered: