2227324689 commented on issue #10829:
URL: https://github.com/apache/dubbo/issues/10829#issuecomment-1294685771
@AlbumenJ
基于对ScopeModel的理解,我尝试的写了一个Demo,你看下是不是这样的一个使用场景。
```java
public class ProviderMain {
public static void main(String[] args) throws InterruptedException {
// 服务提供者暴露服务配置
ServiceConfig<IHelloService> helloServiceConfig = new
ServiceConfig<>();
helloServiceConfig.setInterface(IHelloService.class);
helloServiceConfig.setRef(new HelloService());
// 通过DubboBootstrap简化配置组装,控制启动过程
DubboBootstrap.getInstance()
.application("dubbo-sdk-provider") // 应用配置
.registry(new
RegistryConfig("zookeeper://192.168.8.133:2181?timeout=20000&blockUntilConnectedWait=30"))
// 注册中心配置
.protocol(new ProtocolConfig("dubbo")) // 全局默认协议配置
.service(helloServiceConfig) // 添加ServiceConfig
.start(); // 启动Dubbo
ServiceConfig<IModelService> modelServiceConfig = new
ServiceConfig<>();
modelServiceConfig.setInterface(IModelService.class);
modelServiceConfig.setRef(new ModelService());
//在同一个FrameworkModel中创建多个ApplicationModel
ApplicationModel applicationModel=new
ApplicationModel(FrameworkModel.defaultModel());
applicationModel.setModelName("test-sdk-provider");
DubboBootstrap.getInstance(applicationModel).registry(new
RegistryConfig("nacos://192.168.8.133:8848"))
.application("test-sdk-provider")
.protocol(new ProtocolConfig("dubbo"))
.service(modelServiceConfig)
.start().await();
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]