I've watched Spring Tips: Functional Reactive Endpoints with Spring Framework 5.0 and read a little about spring reactor but I can't quite understand it.
What are the benefits of having endpoints return Flux
/Mono
instances (jacksonified) instead of straight up dto objects (jacksonified), given that I've got netty and spring reactor active? I initially assumed that reactive streams would, in http request/response context, work more like websockets wherein the server pushes the data to the receiver with an open channel but this doesn't seem to be the case.
Also what does netty actually do better in reactive programming than tomcat?
I'm sorry if these questions seem stupid but I don't quite understand the purpose of this new framework direction. Why did it come about, how does it work and what problems does it solve?
I highly suggest you watch the recently presented in Devoxx Belgium "Reactive Web Application with Spring 5" by Rossen Stoyanchev.
In there he talks about how the Reactive Web Controller (presented below) on the surface looks like Spring MVC HTTP Servlet Request/Response Controller but it's actually not
@GetMapping("/users/{id}")
public Mono<User> getUser(@PathValiable Long id) {
return this.userRepository.findById(id);
}
@GetMapping("/users")
public Flux<User> getUsers() {
return this.userRepository.findAll();
}
he talks about how Servlet 3.1
although non-blocking doesn't truely work for fully reactive and how the glue code connecting the Servlet 3.1 and Reactive Streams is implemented as part of the Spring 5 changes for the Servlet 3.1 compliant web containers (Jetty and Tomcat).
And of course he is touching on fully Reactive non-blocking compliant servers (Netty, Undertow) are supported to run Reactive Streams.