The publish operator

Reactor provides the publish operator to generate a ConnectedFlux. Unlike the replay operator, which buffers events received by the first subscriber, the publish operator gets events from the source stream. The operator keeps track of the demands raised by its subscribers. If any subscriber does not raise a demand, it pauses the event generation until a new demand is raised by all of its subscribers. Consider the following diagram:

Just like the replay operator, the ConnectedFlux generated by the publisher also needs subscriber management. Here, we can configure this by using any of the following three options—connect ...

Get Hands-On Reactive Programming with Reactor now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.