Skip to content
thesarfo

Concept

Reactive: Spring WebFlux Intro

What Spring WebFlux is, the reactive drivers it supports, and its two programming models.

views 0

Spring WebFlux

  • A reactive framework introduced in Spring 5.
  • Designed to provide a reactive programming model for building web apps and APIs with Spring.
  • Built on top of Project Reactor, a popular reactive programming library for the JVM.
  • Supported on Tomcat, Jetty, Servlet 3.1+ containers, and non-Servlet runtimes like Netty and Undertow.

Reactive database drivers

Some reactive drivers supported in Spring WebFlux:

  1. Reactive MongoDB driver — reactive support for MongoDB
  2. Reactive Redis driver — reactive support for Redis
  3. Reactive Cassandra driver — reactive support for Cassandra

Spring WebFlux supports two programming models:

  1. Traditional annotation-based model with @Controller, @RequestMapping, and other MVC annotations.
  2. A functional style model based on Java 8 lambdas for routing and handling requests.

Reactive REST APIs are asynchronous and return a Publisher (Mono or Flux).