SubscribeOn operator

The subscribeOn operator intercepts events from a publisher in the execution chain and sends them to a different scheduler for the complete chain. It is important to note that the operator changes the execution context for the complete chain, unlike the publishOn operator, which only alters the execution of a downstream chain:

@Test    public void testReactorSubscribeOn() 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 next of "+ state.getT2());            return Tuples.of(state.getT2(), state.getT1() + state.getT2());        });        fibonacciGenerator                                .filter(x -> { print("Executing ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.