Spring Reactive Programming Module1
Spring Reactive Programming Module1
Overview
deals with data streams and the propagation of change. This model allows applications to scale effectively,
Why Reactive?
- Traditional apps block threads while waiting (e.g., for I/O, DB, etc.)
- Reactive apps use fewer threads, allowing high throughput with minimal resources
Imperative:
System.out.println(name);
Reactive:
nameMono.subscribe(System.out::println);
Spring WebFlux is powered by Project Reactor, which introduces Mono and Flux.
Mono Example
mono.subscribe(System.out::println);
Flux Example
flux.subscribe(System.out::println);
Spring Reactive Programming - Module 1: Introduction
Backpressure
Backpressure allows the subscriber to signal to the publisher that it cannot keep up with the rate of
emissions. Flux and Mono follow the Reactive Streams specification that supports backpressure.
Use Cases
- Streaming APIs
- WebSockets / SSE
- IoT platforms
- High-concurrency apps
Interview Questions