Comparing reactive Spring WebFlux against classic Spring MVC
Ever heard of Spring MVC? It's one of the most popular web frameworks used by the Java community. Since Spring Framework 3, it has utilized an annotation-driven programming style, sometimes known as @MVC
.
But we aren't going to use that in this book. Instead, we are going to use something new, Spring WebFlux. WebFlux is an alternative module in the Spring Framework focused on reactive handling of web requests. A huge benefit is that it uses the same annotations as @MVC
, along with many of the same paradigms while also supporting Reactor types (Mono
and Flux
) on the inputs and outputs. This is NOT available in Spring MVC. The big thing to understand is that it's just a module name--spring-webflux
versus spring-webmvc
.
Why is Spring doing this?
Spring MVC is built on top of Java EE's Servlet spec. This specification is inherently blocking and synchronous. Asynchronous support has been added in later versions, but servlets can still...