☕ Java Advanced

What is Reactive Programming and how does Java support it?

Answer

Reactive programming is a programming paradigm centered on asynchronous data streams and the propagation of change. It handles backpressure — when producers emit data faster than consumers can process — by allowing consumers to signal how much data they can handle. Java supports it through the java.util.concurrent.Flow API (Java 9), which standardizes the Reactive Streams specification with four interfaces: Publisher, Subscriber, Subscription, and Processor. Major frameworks: Project Reactor (used by Spring WebFlux) provides Mono<T> (0-1 elements) and Flux<T> (0-N elements). RxJava provides Observable, Flowable, Single, and Maybe. Reactive is ideal for I/O-bound, high-concurrency scenarios.