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>,java.util.concurrent.Flow.Processor<T,T>,java.util.concurrent.Flow.Publisher<T>,java.util.concurrent.Flow.Subscriber<T>,java.util.concurrent.Flow.Subscription
public class UnicastProcessor<T> extends AbstractMulti<T> implements java.util.concurrent.Flow.Processor<T,T>, java.util.concurrent.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
BackPressureFailureexception 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
Multifrom an emitter, seeMultiCreate.emitter(Consumer, BackPressureStrategy).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()static <I> UnicastProcessor<I>create()Creates a newUnicastProcessorusing a new unbounded queue.static <I> UnicastProcessor<I>create(java.util.Queue<I> queue, java.lang.Runnable onTermination)Creates a newUnicastProcessorusing the given queue.booleanhasSubscriber()Checks whether there is a subscriber listening for the emitted events.voidonComplete()voidonError(java.lang.Throwable failure)voidonNext(T t)voidonSubscribe(java.util.concurrent.Flow.Subscription upstream)voidrequest(long n)SerializedProcessor<T,T>serialized()voidsubscribe(MultiSubscriber<? super T> downstream)-
Methods inherited from class io.smallrye.mutiny.operators.AbstractMulti
broadcast, cache, capDemandsUsing, collect, convert, emitOn, group, ifNoItem, log, log, onCancellation, onCompletion, onFailure, onFailure, onFailure, onItem, onOverflow, onRequest, onSubscription, onTermination, paceDemand, runSubscriptionOn, select, skip, subscribe, subscribe, toHotStream, toUni, withContext
-
-
-
-
Method Detail
-
create
public static <I> UnicastProcessor<I> create()
Creates a newUnicastProcessorusing a new unbounded queue.- Type Parameters:
I- the type of item- Returns:
- the unicast processor
-
create
public static <I> UnicastProcessor<I> create(java.util.Queue<I> queue, java.lang.Runnable onTermination)
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
public void onSubscribe(java.util.concurrent.Flow.Subscription upstream)
- Specified by:
onSubscribein interfacejava.util.concurrent.Flow.Subscriber<T>
-
subscribe
public void subscribe(MultiSubscriber<? super T> downstream)
- Overrides:
subscribein classAbstractMulti<T>
-
onNext
public void onNext(T t)
- Specified by:
onNextin interfacejava.util.concurrent.Flow.Subscriber<T>
-
onError
public void onError(java.lang.Throwable failure)
- Specified by:
onErrorin interfacejava.util.concurrent.Flow.Subscriber<T>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfacejava.util.concurrent.Flow.Subscriber<T>
-
request
public void request(long n)
- Specified by:
requestin interfacejava.util.concurrent.Flow.Subscription
-
cancel
public void cancel()
- Specified by:
cancelin interfacejava.util.concurrent.Flow.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
public SerializedProcessor<T,T> serialized()
-
-