The publishOn operator intercepts events from a publisher at a configured point in the execution chain, and sends them to a different scheduler for the rest of the chain. As a result, the operator changes the threading context of the downstream reactive chain. It is important to note that the operator only influences the downstream event chain. It does not alter the upstream chain, and leaves the upstream execution to the default execution model. The following code shows this:
@Test public void testReactorPublishOn() throws Exception{ Flux<Long> fibonacciGenerator = Flux.generate(() -> Tuples.<Long, Long>of(0L, 1L), (state, sink) -> { if (state.getT1() < 0) sink.complete(); else sink.next(state.getT1()); print("Generating ...