Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

#TypeProsConsRecommend
1FutureFutures return value
Y
2Thread
threads does not return anything as the run() method returns void. We could possibly implement mechanism to trigger a response but this is unnecessary as futures do thisN

RequestID Request ID Generation

...

TypeMethodEase of implementationDecision
UUID
String uniqueID = UUID.randomUUID().toString();
Easy~
CustomWe generate our own  (example exists in NCMP (notificationPublisher - confrm))Medium-
HTTP Request IDFurther investigation required
~
Kafka Event IDFurther investigation required
~

...

Spring WebFlux is a web framework that’s built on top of Project Reactor, to give you asynchronous I/O, and allow your application to perform better. The original web framework included in the Spring Framework, Spring Web MVC, was purpose-built for the Servlet API and Servlet containers. The reactive-stack web framework, Spring WebFlux, was added later in version 5.0. It is fully non-blocking, supports Reactive Streams back pressure, and runs on such servers as Netty, Undertow, and Servlet 3.1+ containers.

spring mvc and webflux vennImage Modified

We suggest that you consider the following specific points:

...

ProsCons
  • Better scalability due to non blocking threads
  • Use less threads (1 per core)
  • Better CPU Efficiency
  • Reactive web programming is great for applications that have streaming data, and clients that consume it and stream it to their users. It ain’t great for developing CRUD apps. If you want to develop a CRUD API, stick with Spring MVC.

  • Steep learning curve in the shift to non-blocking, functional, and declarative programming


Links to materials:

https://www.baeldung.com/spring-webflux

...