public static void main ( String [ ] args ) throws InterruptedException { Microservices ms1 = Microservices . builder ( ) . discovery ( ScalecubeServiceDiscovery :: new ) . transport ( ServiceTransports :: rsocketServiceTransport ) . defaultErrorMapper ( new ServiceAProviderErrorMapper ( ) ) // default mapper for whole node . services ( ServiceInfo . fromServiceInstance ( new ServiceAImpl ( ) ) . errorMapper ( new ServiceAProviderErrorMapper ( ) ) // mapper per service instance . build ( ) ) . startAwait ( ) ; System . err . println ( "ms1 started: " + ms1 . serviceAddress ( ) ) ; Microservices ms2 = Microservices . builder ( ) . discovery ( serviceEndpoint -> serviceDiscovery ( serviceEndpoint , ms1 ) ) . transport ( ServiceTransports :: rsocketServiceTransport ) . services ( call -> { ServiceA serviceA = call . errorMapper ( new ServiceAClientErrorMapper ( ) ) // service client error mapper . api ( ServiceA . class ) ; ServiceB serviceB = new ServiceBImpl ( serviceA ) ; return Collections . singleton ( ServiceInfo . fromServiceInstance ( serviceB ) . build ( ) ) ; } ) . startAwait ( ) ; System . err . println ( "ms2 started: " + ms2 . serviceAddress ( ) ) ; ms2 . call ( ) . api ( ServiceB . class ) . doAnotherStuff ( 0 ) . subscribe ( System . out :: println , th -> System . err . println ( "No service client mapper is defined for ServiceB, " + "so default scalecube mapper is used! -> " + th ) , ( ) -> System . out . println ( "Completed!" ) ) ; Thread . currentThread ( ) . join ( ) ; }
Example runner .