The DirectProcessor type

DirectProcessor is the simplest of the processors. This processor connects a processor to a subscriber, and then directly invokes the Subscriber.onNext method. The processor does not offer any backpressure handling.

An instance of DirectProcessor can be created by invoking the create() method. Any number of subscribers can subscribe to the processor. It must be noted that once the processor has published the complete event, it will reject subsequent data events.

Consider the following code:

DirectProcessor<Long> data = DirectProcessor.create();data.subscribe(t -> System.out.println(t),        e -> e.printStackTrace(),        () -> System.out.println("Finished 1"));data.onNext(10L);data.onComplete();data.subscribe(t -> System.

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.