The UnicastProcessor type

The UnicastProcessor type is like the DirectProcessor, in terms of invocations of the Subscriber.onNext method. It invokes the subscriber method directly. However, unlike the DirectProcessor, the UnicastProcessor is capable of backpressure. Internally, it creates a queue to hold undelivered events. We can also provide an optional external queue to buffer the events. After the buffer is full, the processor starts to reject elements. The processor also makes it possible to perform cleanup for every rejected element.

The UnicastProcessor provides create methods to build an instance of the processor. Let's take a look at the following code to see how this is used:

UnicastProcessor<Long> data = UnicastProcessor.create ...

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.