Module io.smallrye.mutiny
Class UnicastProcessor<T>
java.lang.Object
io.smallrye.mutiny.operators.AbstractMulti<T>
io.smallrye.mutiny.operators.multi.processors.UnicastProcessor<T>
- Type Parameters:
T- the type of item
- All Implemented Interfaces:
Multi<T>,Flow.Processor<T,,T> Flow.Publisher<T>,Flow.Subscriber<T>,Flow.Subscription
public class UnicastProcessor<T>
extends AbstractMulti<T>
implements Flow.Processor<T,T>, Flow.Subscription
Implementation of a processor using a queue to store items and allows a single subscriber to receive
these items.
The back pressure model is not using the request protocol but the queue used to store the items. If the queue
gets full, an BackPressureFailure exception is propagated downstream.
This processor must not be re-subscribed: it expects exactly 1 subscriber.
If you expect multiple subscribers then you should look at creating a Multi from an
emitter, see MultiCreate.emitter(Consumer, BackPressureStrategy).
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()static <I> UnicastProcessor<I> create()Creates a newUnicastProcessorusing a new unbounded queue.static <I> UnicastProcessor<I> Creates a newUnicastProcessorusing the given queue.booleanChecks whether there is a subscriber listening for the emitted events.voidvoidvoidvoidonSubscribe(Flow.Subscription upstream) voidrequest(long n) voidsubscribe(MultiSubscriber<? super T> downstream) Methods inherited from class io.smallrye.mutiny.operators.AbstractMulti
broadcast, cache, capDemandsUsing, collect, convert, emitOn, emitOn, group, ifNoItem, log, log, onCancellation, onCompletion, onFailure, onFailure, onFailure, onItem, onOverflow, onRequest, onSubscription, onTermination, paceDemand, pauseDemand, runSubscriptionOn, select, skip, subscribe, subscribe, toHotStream, toUni, withContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.Flow.Publisher
subscribe
-
Method Details
-
create
Creates a newUnicastProcessorusing a new unbounded queue.- Type Parameters:
I- the type of item- Returns:
- the unicast processor
-
create
Creates a newUnicastProcessorusing the given queue.- Type Parameters:
I- the type of item- Parameters:
queue- the queue, must not benullonTermination- the termination callback, can benull- Returns:
- the unicast processor
-
onSubscribe
- Specified by:
onSubscribein interfaceFlow.Subscriber<T>
-
subscribe
- Overrides:
subscribein classAbstractMulti<T>
-
onNext
- Specified by:
onNextin interfaceFlow.Subscriber<T>
-
onError
- Specified by:
onErrorin interfaceFlow.Subscriber<T>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceFlow.Subscriber<T>
-
request
public void request(long n) - Specified by:
requestin interfaceFlow.Subscription
-
cancel
public void cancel()- Specified by:
cancelin interfaceFlow.Subscription
-
hasSubscriber
public boolean hasSubscriber()Checks whether there is a subscriber listening for the emitted events. Mostly for testing purpose.- Returns:
trueif there is a subscriber,falseotherwise
-
serialized
-