use of org.apache.dubbo.config.bootstrap.EchoService in project dubbo by alibaba.
the class DubboInterfaceConsumerBootstrap method main.
public static void main(String[] args) throws Exception {
RegistryConfig interfaceRegistry = new RegistryConfig();
interfaceRegistry.setId("interfaceRegistry");
interfaceRegistry.setAddress("zookeeper://127.0.0.1:2181");
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application("dubbo-consumer-demo").registry(interfaceRegistry).reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo")).reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest")).start().await();
EchoService echoService = bootstrap.getCache().get(EchoService.class);
UserService userService = bootstrap.getCache().get(UserService.class);
for (int i = 0; i < 500; i++) {
Thread.sleep(2000L);
System.out.println(echoService.echo("Hello,World"));
System.out.println(userService.getUser(1L));
}
}
use of org.apache.dubbo.config.bootstrap.EchoService in project dubbo by alibaba.
the class PublishingServiceDefinitionListenerTest method testOnServiceConfigExportedEvent.
/**
* Test {@link ServiceConfigExportedEvent} arising
*/
@Test
public void testOnServiceConfigExportedEvent() {
ServiceConfig<EchoService> serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(EchoService.class);
serviceConfig.setRef(new EchoServiceImpl());
serviceConfig.setRegistry(new RegistryConfig("N/A"));
serviceConfig.setProtocol(new ProtocolConfig("dubbo", NetUtils.getAvailablePort(20880 + new Random().nextInt(10000))));
serviceConfig.export();
String serviceDefinition = writableMetadataService.getServiceDefinition(EchoService.class.getName());
ServiceDefinition serviceDefinitionBuild = ServiceDefinitionBuilder.build(serviceConfig.getInterfaceClass());
assertEquals(serviceDefinition, JSON.toJSONString(serviceDefinitionBuild));
serviceConfig.unexport();
}
Aggregations