To understand it better, let's play with the Reactor. We will implement and understand the difference between hot and cold publishers in practice.
Cold publishers do not produce any data until a new subscription arrives. In the following code, we will create a cold publisher and the System.out:println will never be executed because it does not have any subscribers. Let's test the behavior:
@Testpublic void coldBehavior(){ Category sports = new Category(); sports.setName("sports"); Category music = new Category(); sports.setName("music"); Flux.just(sports,music) .doOnNext(System.out::println);}
As we can see, the method subscribe() is not present in this snippet. When we execute the code, we will not see any data ...