use of io.scalecube.services.examples.helloworld.service.api.GreetingsService in project scalecube by scalecube.
the class Example1 method main.
/**
* Start the example.
*
* @param args ignored
*/
public static void main(String[] args) {
// ScaleCube Node with no members
Microservices seed = Microservices.builder().discovery(serviceEndpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(serviceEndpoint))).transport(RSocketServiceTransport::new).startAwait();
final Address seedAddress = seed.discovery().address();
// Construct a ScaleCube node which joins the cluster hosting the Greeting Service
Microservices ms = Microservices.builder().discovery("ms", endpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(endpoint)).membership(cfg -> cfg.seedMembers(seedAddress))).transport(RSocketServiceTransport::new).services(new GreetingServiceImpl()).startAwait();
// Create service proxy
GreetingsService service = seed.call().api(GreetingsService.class);
// Execute the services and subscribe to service events
service.sayHello("joe").subscribe(consumer -> System.out.println(consumer.message()));
Mono.whenDelayError(seed.shutdown(), ms.shutdown()).block();
}
Aggregations