liveBook · Manning

Project Reactor

As explained in Spring Security in Action, Second Edition

Project Reactor is a Java library that provides reactive programming types and operators for composing asynchronous streams.

Project Reactor is a Java library that implements Reactive Streams and provides a functional API for composing asynchronous streams in Spring’s reactive programming model. section 17.1

Use its core types to model reactive web endpoints:

  • Return Mono for a publisher that produces a single value, such as a HelloController endpoint returning Mono.just("Hello!"). section 17.1
  • Use Flux alongside Mono when working with publishers of reactive data streams. section 17.1

Reactive endpoint

A Spring web endpoint can return Mono<String> and produce its response with Mono.just("Hello!"). The reactive web dependency enables Project Reactor classes and interfaces.

Figure 17.1 Non-reactive vs. reactive. In a non-reactive approach, the milk factory gets all the milk to be packaged in the morning and delivers all the boxes in the evening. In a reactive approach, as the milk is brought to the factory, it’s packaged and then delivered. For this scenario, a reactive approach is better as it allows milk to be collected throughout the day and delivered sooner to the clients.

Compare reactive processing, which collects and delivers work progressively, with non-reactive processing, which waits for the complete batch. section 17.1

How Spring Security in Action, Second Edition covers it

How deep it goes
Defines Reactive Streams roles and demonstrates a Mono endpoint, but stops short of detailed operator or scheduling internals.
Examples
Uses a milk-factory analogy, a HelloController endpoint, curl invocation, and Mono.just("Hello!") output.
What it assumes
Assumes basic Java and Spring web development while introducing Reactive Streams publishers and subscribers.
What you can do after
Build a simple reactive web endpoint using Spring WebFlux and Reactor’s Mono publisher.
How it connects
Connects Reactive Streams, Publisher, Subscriber, Mono, Flux, Spring WebFlux, and Spring’s reactive programming model.

Also explained in

Compare how 2 books explain Project Reactor →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Security in Action, Second Edition. The section links point to the parts of the book it draws on.