Source:
public static void main(String[] args) throws Exception { System.out.println("Start gateway"); Microservices gateway = Microservices.builder() .discovery(ScalecubeServiceDiscovery::new) .transport(ServiceTransports::rsocketServiceTransport) .gateway(opts -> new HttpGatewayStub(opts.id("http").port(8181))) .gateway(opts -> new WebsocketGatewayStub(opts.id("ws").port(9191))) .startAwait(); System.out.println("Start HelloWorldService with BusinessLogicFacade"); final Microservices node1 = Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, gateway)) .transport(ServiceTransports::rsocketServiceTransport) .services( call -> Collections.singleton( ServiceInfo.fromServiceInstance( new HelloWorldServiceImpl( new BusinessLogicFacade( call.create().api(ServiceHello.class), call.create().api(ServiceWorld.class)))) .build())) .startAwait(); System.out.println("Start ServiceHello"); final Microservices node2 = Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, gateway)) .transport(ServiceTransports::rsocketServiceTransport) .services(new ServiceHelloImpl()) .startAwait(); System.out.println("Start ServiceWorld"); final Microservices node3 = Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, gateway)) .transport(ServiceTransports::rsocketServiceTransport) .services(new ServiceWorldImpl()) .startAwait(); System.out.println("Wait for some time so nodes could catch up with each other ..."); TimeUnit.SECONDS.sleep(3); System.out.println("Making hello world business logic ..."); HelloWorldService helloWorldService = node1.call().create().api(HelloWorldService.class); String helloWorld = helloWorldService.helloWorld().block(Duration.ofSeconds(6)); System.out.println("Result of calling hello world business logic is ... => " + helloWorld); Mono.when(gateway.shutdown(), node1.shutdown(), node2.shutdown(), node3.shutdown()) .block(Duration.ofSeconds(5)); }

Target:
public static void main(String[] args) throws Exception { System.out.println("Start gateway"); Microservices gateway = Microservices.builder() .discovery(ScalecubeServiceDiscovery::new) .transport(ServiceTransports::rsocketServiceTransport) .gateway(opts -> new HttpGatewayExample(opts.id("http").port(8181))) .gateway(opts -> new WebsocketGatewayExample(opts.id("ws").port(9191))) .startAwait(); System.out.println("Start HelloWorldService with BusinessLogicFacade"); final Microservices node1 = Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, gateway)) .transport(ServiceTransports::rsocketServiceTransport) .services( call -> Collections.singleton( ServiceInfo.fromServiceInstance( new HelloWorldServiceImpl( new BusinessLogicFacade( call.api(ServiceHello.class), call.api(ServiceWorld.class)))) .build())) .startAwait(); System.out.println("Start ServiceHello"); final Microservices node2 = Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, gateway)) .transport(ServiceTransports::rsocketServiceTransport) .services(new ServiceHelloImpl()) .startAwait(); System.out.println("Start ServiceWorld"); final Microservices node3 = Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, gateway)) .transport(ServiceTransports::rsocketServiceTransport) .services(new ServiceWorldImpl()) .startAwait(); System.out.println("Wait for some time so nodes could catch up with each other ..."); TimeUnit.SECONDS.sleep(3); System.out.println("Making hello world business logic ..."); HelloWorldService helloWorldService = node1.call().api(HelloWorldService.class); String helloWorld = helloWorldService.helloWorld().block(Duration.ofSeconds(6)); System.out.println("Result of calling hello world business logic is ... => " + helloWorld); Mono.when(gateway.shutdown(), node1.shutdown(), node2.shutdown(), node3.shutdown()) .block(Duration.ofSeconds(5)); }