- define java service dsl using interface.
@Service("greeting")
public interface GreetingService {
@ServiceMethod("once")
Mono<String> sayHello(String name);
@ServiceMethod("many")
Flux<String> sayHellos(String name);
@ServiceMethod("timer")
Flux<String> timerHello(String name);
}
- implement the service dsl.
public class SimpleGreetingService implements GreetingService {
@Override
public Mono<String> sayHello(String name) {
return Mono.just("greeting to: "+ name);
}
@Override
public Flux<String> sayHellos(String name) {
return Flux.range(0, 3).map(i -> "greeting to: " + name + "-" + i);
}
@Override
public Flux<String> timerHello(String name) {
return Flux.interval(Duration.ofSeconds(1)).map(i -> "greeting to: " + name + "-" + i);
}
}
- running the service.
- RequestResponseMain
- RequestStreamMain
- GreetingServiceMain and ServiceGatewayMain
- Api-Sandbox: 4.1. open in browser: http://scalecube.io/api-sandbox/app/index.html
4.2. click settings and choose Rsocket and set url ws://localhost:9090
4.3. input json request and click send:
select: