A reactive stream handles data as it arrives instead of waiting for an entire dataset. Think of a garden hose rather than a water balloon: the flow can continue for as long as new data arrives. A stream of real-time temperature readings, for example, might never end. section 11.1
Reactive Streams is a standard for asynchronous stream processing with nonblocking backpressure. Unlike Java streams, which are typically synchronous and operate on finite collections, Reactive Streams can process an unbounded sequence. Backpressure lets a consumer limit how much data it accepts from a faster producer. section 11.1.1
Four interfaces describe the exchange:
- A Publisher produces items for a Subscriber. section 11.1.1
- A Subscription lets the Subscriber request items or cancel. section 11.1.1
- A Subscriber receives subscription, item, error, and completion notifications. section 11.1.1
- A Processor is both a Subscriber and a Publisher. section 11.1.1
public interface Subscription {
void request(long n);
void cancel();
}
The Subscription interface makes backpressure concrete: request(n) states how many items the subscriber is ready to receive; cancel() ends its subscription. section 11.1.1
A greeting pipeline
Reactor’s Mono.just() supplies one name, two map() operations change it into a greeting, and subscribe() receives and prints the result. The code describes a pipeline; it does not guarantee that every operation runs on a different thread. section 11.2
Mono.just("Craig")
.map(n -> n.toUpperCase())
.map(cn -> "Hello, " + cn + "!")
.subscribe(System.out::println);
Follow the value from just() through each map() to subscribe(). Reactor’s Mono publishes at most one item; its Flux can publish zero, one, or many, potentially without end. section 11.2
JDK 9’s Flow interfaces correspond to the four Reactive Streams interfaces, but the Flow APIs are not themselves a Reactive Streams implementation. section 11.1.1



