
Explore reactive programming fundamentals with Spring WebFlux through hands-on practice, focusing on responsive, resilient, and scalable microservices, streaming patterns, and the four reactive principles.
Create a maven spring boot playground project to learn spring web flex and reactive data access with two DBC. Import into your IDE and bookmark the GitHub link for updates.
Compare the traditional and reactive approaches by building a simple app that calls an external product service and exposes both controllers as endpoints.
Compare traditional and reactive web controllers for product data, fetching from a remote service with a rest client and a web client, returning a list or a flux of products.
Compare traditional and reactive API behavior through a live demo. See traditional endpoints buffer until all results arrive, while reactive endpoints stream items as they arrive.
See how reactive vs traditional APIs differ by demoing a browser request to the reactive product controller and a traditional workflow, focusing on how cancellation and buffering behave during refresh.
Expose a streaming API by configuring a reactive endpoint with text/event-stream so the browser renders product data as items arrive.
Identify the common mistake of misusing blocking code as reactive. Learn why external calls must stay inside the reactive pipeline, illustrated by the tank and pipeline analogy.
Explore how reactive web works end-to-end with the publisher-subscriber pattern in Spring Web Flux, enabling reactive microservices, streaming data non-blocking from back end to browser and handling subscribe and cancel.
Evaluate when to migrate from Spring MVC to Spring WebFlux, starting with one app, to gain back pressure benefits while improving resource efficiency across the stack.
The lecture demonstrates how reactive web clients can handle failures from downstream services, returning partial responses and using on error complete to improve resilience in a microservices setting.
Review the differences between reactive and traditional APIs and preview how WebFlux supports responsive, streaming applications with early cancellation, while outlining topics like database calls, CRUD APIs, and error handling.
Explore the differences between R2DBC and JPA, focusing on reactive relational database connectivity, performance, streaming with back pressure, and simple entity mapping using Spring Data R2DBC.
Discover how to provide the connection string for Postgres, MySQL, and H2, using the spring.datasource.url property with username and password, while Spring handles automatic configuration.
Set up a three-table schema for customer, product, and customer order with uuid keys and foreign keys, initialize with sample data, and configure scanning and r2dbc repositories for Spring WebFlux.
Define an entity class mapped to the customer table and extend a reactive CRUD repository to enable create, read, update, and delete operations with automatic query generation.
Define a reactive customer entity with id, name, and email, map table and columns, and build a reactive repository with mono/flux returns; set up test scaffolding for section zero two.
Develop skills with the step verifier to test publishers from services, controllers, or repositories by asserting next items and expecting complete or error signals.
Demonstrates reactive CRUD with a customer repository in Spring WebFlux, covering find all, find by id, and reactive query methods like find by email ending with, using flux and mono.
Demonstrates crud using a customer repository by inserting a customer, verifying the auto-generated id with mono and step verifier, counting records, and deleting by id, then verifying the updated count.
Update a customer record in a reactive pipeline by using doOnNext to mutate the entity, then save via flatMap, showcasing non-blocking, sequential updates.
R2dbc has no show SQL property like JPA; for debugging, set the logging level to debug for the org spring framework auto db package to display SQL statements.
Create a product entity and a reactive repository with a find by price between method to fetch all products in a given price range, and test with StepVerifier.
Discover paginated data retrieval in Spring WebFlux using pageable, page requests, zero-indexed pages, and optional price sorting to fetch the first three products.
Explore how to perform complex queries with r2dbc using simple sql statements for joins, via repository query annotations or the database client, and design a customer order repository.
Learn to join customer, order, and product data to list products ordered by a given customer using @Query in Spring Data JDBC, and verify results with a step verifier.
Learn to fetch order details by projecting joined customer, order, and product data, including customer name, product description, and amount, ordering results by amount in descending order using Java records.
Explore the R2DBC database client in a Spring WebFlux microservice, executing arbitrary SQL with bind inputs and mapping results to a class, returning a flux of order details.
Explore reactive data access with DBC, distinct from JPA, and leverage Spring Data for repository queries and projections. Emphasize performance, scalability, backpressure, and raw SQL for joins.
Compare reactive spring data r2dbc with spring data jpa, evaluating throughput and efficiency on a Postgres setup with 10 million records to reveal resource usage.
Compare reactive versus traditional throughput and efficiency through dockerized tests. Highlight r2dbc versus jdbc, virtual threads, and memory usage across varying ram.
Discover how R2DBC enables reactive, non-blocking data access by streaming results with backpressure, preventing memory blowups and delivering efficient, scalable database reads in Spring WebFlux.
Use Spring Data JPA with Spring WebFlux by using the JPA module and a bounded elastic scheduler to avoid blocking the event loop; monitor performance with tools like New Relic.
The reactive manifesto outlines four principles—responsive, resilient, elastic, and message driven—that shape reactive microservices into highly responsive, resilient, and scalable systems for distributed architectures, cloud computing, and real-time data processing.
Expose customer CRUD APIs with Spring Flex, including get all, get by id, create, update by id, and delete, while building service and controller components.
Evaluate when to use data transfer objects versus entity classes, and how DTOs enable API versioning, security, and validation while decoupling the API from the database.
Define a customer dto as a record with id, name, and email, and implement an entity dto mapper with static methods to convert between dto and entity.
Builds a reactive service layer for customer data using spring webflux, implementing get all, get by id, save, update, and delete endpoints with dto mappings, using flux and mono.
expose all CRUD APIs through a reactive customer controller using Spring WebFlux, returning flux and mono payloads for get all, get by id, save, update, and delete operations.
Compare using a DTO vs Mono of DTO for @RequestBody in Spring WebFlux, explaining deserialization, reactive pipeline invocation, and streaming advantages in inter-service communication.
Test customer CRUD APIs with postman, validating get all, get by id, create, update, and delete, while configuring the app and observing 200 responses.
Explain how spring webflux uses mono and flux, and how to return status codes with mono of response entity for typical requests, reserving flux for streaming.
Handle 4xx via response entity for get, update, and delete in Spring WebFlux, using Mono, map, and defaultIfEmpty to return not found when the customer is absent.
Learn to use the modifying query annotation in Spring WebFlux to delete a customer by id, returning mono of boolean or integer and handling the response in the controller.
Implement paginated results for customers using a /customers paginated endpoint with page and size parameters, zero-based indexing, and collectList.
Test the reactive crud APIs with postman by getting all and paginated customers, getting by id, creating and updating a customer, and deleting, observing 200 and 404 responses.
Use webTestClient to test your controller APIs with non-blocking http requests in unit and integration tests, validating status, headers, and json path content.
Write and validate integration tests for a reactive microservice using the web test client, asserting status 200, content type, and JSON body for all and paginated customer endpoints.
Perform integration tests for customer endpoints in a reactive microservices API, validating get by id, create, delete, and update operations with accurate status and fields (id, name, email).
Master integration testing in Spring WebFlux by validating not found errors for get, delete, and put requests, checking 400/404 responses, and ensuring test isolation.
Compare the body and body value methods in reactive web tests and clients, explaining when to use a concrete object versus a Mono or Flux publisher in non-blocking I/O.
Expose rest APIs with Spring WebFlux, manage http status using ResponseEntity and Mono, and prepare for validation, error handling via controller advice, with testing via WebTestClient.
validate input with a name and email dto, enforce non-null and format, and return errors via controller advice using problem detail (RFC 7807/9457) fields type, title, status, detail, and instance.
Learn how to implement custom validation in Spring WebFlux without the bean validation dependency, using manual validation techniques and understanding when bean validation is optional.
Set up the project in your ide by creating a new section zero four package, copying from section zero three, and adding packages for exception, validator, and controller advice.
Create application exceptions for a Spring WebFlux microservice, including customer not found and invalid input, plus an exception factory that emits Mono.error with clear messages for missing or invalid data.
Explore the request validator for a customer dto, validating name and email via a reactive mono pipeline and switchIfEmpty to throw missing name or missing valid email.
Explore reactive validation in a Spring WebFlux microservice, using Mono and request validator to emit error signals for not found customers and invalid requests, via switchIfEmpty.
Learn to build a robust exception handling layer with @ControllerAdvice in a Spring WebFlux microservices app, handling customer not found and invalid input exceptions and returning structured problem detail.
Demonstrates testing a reactive microservice API with Postman, validating get all, paginated results, by-id lookups, and create, update, and delete operations with input validation.
Create an integration test for the source test java in section 04, using section 03 as reference, and validate detail message in error responses, focusing on the problem detail object.
Implement integration tests for reactive microservices by validating happy path scenarios, not-found responses, and input validation with missing fields and invalid emails, using JSON path details and post/put requests.
Learn to validate input and emit standardized error signals, catch them in your controller, and return appropriate messages using the standardized problem detail format.
Explore how a web filter sits before the controller to enforce cross-cutting concerns such as authentication, authorization, logging, monitoring, and rate limiting, with header validation examples.
Explore how web filters in Spring WebFlux form a chain, validate requests, and forward them to the next filter or controller using chain.filter(exchange, next), with order annotation controlling execution order.
Implement authentication and authorization with a web filter, using an auth token header to distinguish standard and prime users and enforce 401 and 403, standard users limited to get.
Implement a reactive web filter in Spring WebFlux that validates an auth token from request headers against a token category map, allowing requests or returning 401 unauthorized.
Learn to implement authentication and authorization web filters in spring webflux, with ordered execution, using exchange attributes to distinguish prime and standard users and enforce get-only access.
Demonstrates how the authentication web filter enforces token-based access: requests without a token or with invalid tokens yield 401; a valid prime token allows post while standard tokens are forbidden.
Access a request attribute in a Spring WebFlux controller after a filter sets it, using attribute name and type, and pass data from filter to controller.
Demonstrate sending the problem detail from a web filter with a manual workaround using server web exchange, due to unsupported error signaling and controller advice.
Create an integration test with Spring Boot test and web test client to validate http status codes: no token or invalid token unauthorized; get succeeds; put/post/delete may be forbidden.
Explore integration testing techniques using private helper methods to validate get and post requests, token-based authorization, and http status expectations in reactive microservices.
Explore web filters for handling cross-cutting concerns in Spring WebFlux, learn how to validate requests before the controller, control filter execution order, and share request attributes across filters and controllers.
Explore functional endpoints in Spring WebFlux, compare them to annotated controllers, and see how routing logic can live as a bean with optional programmatic APIs and flexible service layer routing.
Explore building a reactive request handler in Spring WebFlux, routing to a service with mono and flux responses, handling path variables, request bodies, validation, and errors for customer endpoints.
Route requests to the corresponding handler using path patterns and request predicates, mapping endpoints for all customers, by id, to get, save, update, and delete, with error handling to follow.
Learn to implement reactive error handling in router functions with exception handlers and problem details, handling customer not found and invalid input exceptions, returning a mono of server response.
Implement a paginated customers endpoint in spring webflux by parsing page and size query parameters, applying defaults, and returning a finite list by collecting the flux.
Explain the order of routes in router functions, how HTTP method and path pattern route requests to handlers, and the need for careful route arrangement for paginated customer requests.
Demonstrates testing a reactive spring webflux microservice with postman, validating CRUD operations on customers, including pagination, proper 404 handling, and input validation for email and name.
Write the integration test in the existing test package and verify functional endpoints expose APIs without introducing new functionality.
Learn how to organize many endpoints using multiple router functions and beans, expose get, post, and delete routes, and understand error handling without a dedicated error handler.
Route all requests with a high level router function to nested child routers using path based logic; ensure order matters for correct matching of customers, paginated results, and ids.
Discover how to implement web filters in a Spring WebFlux router function, extract request data, pass to the next filter, and conditionally return a bad request.
Explore how request predicates enhance routing by evaluating the server request against path patterns, headers, and query parameters to select the appropriate handler in a reactive router function.
Implement a simple calculator api with /calculator/{a}/{b}, using an operation header (plus, minus, multiplication, divide by) to return a raw result or 400 bad request, exploring request predicate.
Presents a functional Spring WebFlux calculator solution using router functions, with operation header predicates, parsing a and b, handling plus and minus, and validating inputs.
Explore functional endpoints as a lightweight alternative to annotated controllers, handling a single request with a single response. Route by method or path using multiple router functions, with optional filters.
Discover how to use the web client as a reactive rest template for non-blocking, immutable calls to external services, with per-service clients, and mono or flux responses.
Design and reuse a web client utility to send requests, inspect responses, and log results using a configurable web client builder with a base url and an optional consumer.
Perform a simple get request with a web client to fetch a product by id, map the response to a product with id, description, and price, and subscribe.
Demonstrates non-blocking concurrent requests with a web client built on the reactor network, showing how a single thread can handle multiple product requests simultaneously and return all responses quickly.
Explain how a single thread per CPU processes hundreds of concurrent requests for a React Native web client using outbound and inbound queues in a non-blocking I/O model.
Learn to build robust URIs with the web client using URI variables, replacing string concatenation with index-based and map-based patterns for clean URL construction, and sending concurrent requests.
Explore streaming get demos that return product stream from 1 to 10 with 500 ms delays, using a non-blocking web client, and apply take to limit to first three seconds.
Learn how to send post requests with a WebClient using body value and body with publisher types in Spring WebFlux, including Mono responses and asynchronous behavior.
Learn to configure a web client with a default caller-id header and override it per request, enabling secure inter-service calls in a Spring WebFlux reactive microservices setup.
Explore decoding error responses from a remote service and handling errors in a reactive web client, including problem detail objects and on error operators for defaults or specific responses.
Explore when to use retrieve versus exchange in Spring WebFlux, and how exchange exposes a client response with status, headers, and cookies for decoding and error handling in mono.
Learn to send query parameters using a URI builder for a calculator-style endpoint, contrasting path and query parameters and exploring map-based parameter replacement and error handling.
Learn to send basic auth credentials with a web client, using an authorization header and base64 encoding, as wrong credentials yield 401 and correct ones succeed against the product endpoint.
Demonstrate setting the bearer token in the web client's headers for authenticated requests, showing a valid token yields a proper response while a missing or invalid token triggers a 401.
Explore the exchange filter function, the outgoing counterpart to a web filter, to attach a new bearer token per request via a client request builder and enable logging and monitoring.
Create an exchange filter function to log the http method and the url for every request, and attach this request logger as a web filter.
Explore how web client attributes pass key-value information across filters, controllers, and service classes to control logging, including enabling logging for even product ids only.
Use web client for reactive, non-blocking http requests, configure a shared bean, build urls with variables, and choose retrieve or exchange with filters for cross-cutting concerns.
Explore streaming in Spring WebFlux and the Web Flex reactive model, contrasting request-response with server streaming, client streaming, and bi-directional patterns, using examples like file downloads and ride updates.
Discover streaming between backend services to upload millions of products efficiently, avoiding repeated authentication and rate-limiting hassles with a single connection. Use json for complex data instead of csv.
Explore the JSON line format, learn line-by-line parsing for streaming and memory efficiency, and understand why new line delimited JSON is preferred over JSON arrays for large data sets.
Set up a reactive microservice project for streaming with a product entity, repository, dto, and mapper, then scaffold controllers and services for uploading, downloading, and product management.
Build a reactive product service in Spring WebFlux by mapping product dto to entity, saving via repository save all, and exposing a total count with mono of long.
Expose a product streaming upload API through a reactive controller, consuming newline-delimited json via a flux, and return an upload response with a uuid and the current products count.
Create a reactive product client that posts a flux of product dto objects to the api's /products/upload endpoint using a web client and streaming json, receiving a single upload response.
Explore a practical client streaming demo in the Spring WebFlux Masterclass: reactive microservices, uploading multiple products with flux delays, observing non-blocking mono responses, and testing streaming behavior from a client.
Learn how to read the request body in a non-blocking way using a publisher type in Spring, enabling streaming post requests that upload multiple products with a single invocation.
Upload a million products in a streaming fashion with a reactive Spring WebFlux product service and expose a streaming download API for all products via Flux.
Explore a Spring WebFlux reactive microservice workflow to implement a download api that streams all products as product dtos, using flux, mapping, and explicit accept and content-type handling.
Showcases downloading 1 million products via a flux of strings, writing them to a single products.txt file with a file writer, and validating completion via step verifier.
Explore bidirectional streaming by combining client streaming and server streaming, returning a flux of product video as soon as created while receiving incoming products in real time.
Explore streaming communication with Spring WebFlux, compare Mono for request-response to the publisher type for large data transfers, and use the newline-delimited JSON media type for non-blocking data.
The course project is up to date Spring Boot 4.0
This Masterclass is the practical, complete guide to Spring WebFlux. You will master Non-Blocking I/O techniques, leveraging Reactive Programming principles, to build highly scalable and resilient microservices. The core focus is on maximizing performance and throughput by eliminating thread blocking. Learn advanced Spring Boot and Spring WebFlux skills including R2DBC for reactive data access, and HTTP/2 Streaming for optimal inter-service communication. This course delivers the expertise needed to transform your enterprise architecture for high-concurrency demands.
What You Will Master: Core Skills & Performance
Every module is designed to provide you with an immediate, high-value, and actionable skill:
Reactive vs. Traditional APIs: Understand the architectural shift from blocking to Non-Blocking I/O. Master the fundamental differences between Traditional APIs and Reactive APIs for maximum scalability.
Reactive Data Access & Benchmarking (R2DBC): Implement non-blocking data access using R2DBC drivers and Spring Data R2DBC repositories. Benchmark and prove the throughput and resource efficiency of R2DBC against Spring Data JPA.
Reactive Controller Development: Master creating reactive controllers, handling requests and responses using Flux/Mono, and validating logic using the dedicated WebTestClient tool.
Advanced Error Handling: Discover techniques for managing exceptions within reactive pipelines. Implement strategies to return meaningful, consistent error responses for a robust user experience.
WebFilter Chaining & Cross-Cutting Concerns: Explore how to implement and chain multiple WebFilters for complex logic. Master pre-processing and post-processing requests and effectively share data across the reactive flow.
Functional Programming in WebFlux: Leverage the power of lambda expressions to write concise, readable code. Build controllers using the modern functional endpoints (Router Functions) pattern.
Building Non-Blocking Clients (WebClient): Learn to use WebClient to consume external APIs asynchronously using reactive streams. Handle asynchronous responses efficiently in a truly non-blocking manner.
Streaming & Real-Time Data: Implement client-side and server-side data streaming for large file transfers using WebClient. Master backpressure handling for optimized performance. Enable real-time updates using Server-Sent Events (SSE) with Spring WebFlux.
Optimizing for Performance (Microservice Communication): Implement Gzip compression for maximum bandwidth savings. Configure HTTP connection pooling to reduce connection overhead. Leverage HTTP/2 protocol and multiplexing for efficient concurrent communication.
Integration Testing Mastery: Master end-to-end testing with WebTestClient, embedding rigorous testing practices throughout the entire course.
By the end of this course, you will be the expert ready to build modern, high-throughput, and scalable Spring WebFlux microservices that maximize resource efficiency under load.