View on GitHub

ScaleCube Reactive Microservices

The Future is reactive - The Future is right here!

Implementing services

Implementing a service is simple as implementing the service interface. As you can see its pure java, so your model and implementation stays clean. One more benefit of such an approach comes when testing your service. Building the service is just like building any other java component.

For example:

import reactor.core.publisher.Mono;
import reactor.core.publisher.Flux;


public class GreetingServiceImpl implements GreetingService {
 @Override
 public Mono<GreetingResponse> greeting(GreetingRequest request) {
   return Mono.just(
     new GreetingResponse("Hello " + request.name())
   );
 }

 @Override
 public Flux<GreetingResponse> greetingStream(GreetingRequest request) {
   return Flux.just(
     new GreetingResponse("Hello " + request.name())
   );
 }
}

Java Class

The service is a simple java class with one or more service methods. a service method may return Reactor Project Mono | Flux or void in case no result is expected. Service requests might be a local or remote call and should not block the service consumer (unless the consumer explicitly called the Mono.block()