Skip to Content
Hands-On Reactive Programming in Spring 5
book

Hands-On Reactive Programming in Spring 5

by Oleh Dokuka, Igor Lozynskyi
October 2018
Intermediate to advanced
556 pages
15h 18m
English
Packt Publishing
Content preview from Hands-On Reactive Programming in Spring 5

Hot and cold streams

When talking about reactive publishers, we may distinguish two types of publishers—hot and cold.

Cold publishers behave in such a way that, whenever a subscriber appears, all of the sequence data is generated for that subscriber. Also, with a cold publisher, no data would be generated without a subscriber. For example, the following code represents the behavior of a cold publisher:

Flux<String> coldPublisher = Flux.defer(() -> {    log.info("Generating new items");    return Flux.just(UUID.randomUUID().toString());});log.info("No data was generated so far");coldPublisher.subscribe(e -> log.info("onNext: {}", e));coldPublisher.subscribe(e -> log.info("onNext: {}", e));log.info("Data was generated twice for two subscribers"
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Spring Microservices in Action, Second Edition

Spring Microservices in Action, Second Edition

John Carnell, Illary Huaylupo Sanchez

Publisher Resources

ISBN: 9781787284951Supplemental Content