use of org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE in project dubbo by alibaba.
the class NacosDubboServiceProviderBootstrap method main.
public static void main(String[] args) {
ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-nacos-provider-demo");
applicationConfig.setMetadataType(REMOTE_METADATA_STORAGE_TYPE);
DubboBootstrap.getInstance().application(applicationConfig).registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?username=nacos&password=nacos").parameter(REGISTRY_TYPE_KEY, SERVICE_REGISTRY_TYPE)).protocol("dubbo", builder -> builder.port(20885).name("dubbo")).protocol("rest", builder -> builder.port(9090).name("rest")).service(builder -> builder.id("echo").interfaceClass(EchoService.class).ref(new EchoServiceImpl()).protocolIds("dubbo")).service(builder -> builder.id("user").interfaceClass(UserService.class).ref(new UserServiceImpl()).protocolIds("rest")).start().await();
}
use of org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE in project dubbo by alibaba.
the class NacosDubboServiceConsumerBootstrap method main.
public static void main(String[] args) throws Exception {
ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-nacos-consumer-demo");
applicationConfig.setMetadataType(REMOTE_METADATA_STORAGE_TYPE);
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(applicationConfig).registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry-type=service").useAsConfigCenter(true).useAsMetadataCenter(true)).reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo")).reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest")).start();
EchoService echoService = bootstrap.getCache().get(EchoService.class);
UserService userService = bootstrap.getCache().get(UserService.class);
for (int i = 0; i < 5; i++) {
Thread.sleep(2000L);
System.out.println(echoService.echo("Hello,World"));
System.out.println(userService.getUser(i * 1L));
}
}
Aggregations