I'm approaching Spring Boot 2 and its reactive way to implement web services. As almost everybody who is used to program with classic synchronous MVC pattern, I have some doubts about this approach. I'm trying to implement a restcontroller and to develop some reactive and non-reactive methods as title of example, in order to understand better the concepts. For instance, importing WebFlux (which uses Netty as Embedded Server) in the way they are written, are the second and the fourth methods reactive, while the first and the third method non-reactive?
@org.springframework.web.bind.annotation.RestController
public class RestController {
@Autowired
NoteDao noteDao;
/* non-reactive */
@RequestMapping("/hello")
public String sayHello(){
return "Hello pal";
}
/* reactive */
@RequestMapping("/hello/reactive")
public Mono<String> sayHelloReactively(){
return Mono.just("Hello reactively, pal!");
}
/* non-reactive */
@RequestMapping("/notes")
public List<Note> getAllNotes(){
return noteDao.findAll();
}
/* reactive */
@RequestMapping("/notes/reactive")
public Flux<List<Note>> getAllNotesReactively(){
return Flux.just(noteDao.findAll());
}
}