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>
,org.reactivestreams.Processor<T,T>
,org.reactivestreams.Publisher<T>
,org.reactivestreams.Subscriber<T>
,org.reactivestreams.Subscription
public class UnicastProcessor<T> extends AbstractMulti<T> implements org.reactivestreams.Processor<T,T>, org.reactivestreams.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, seeMultiCreate.emitter(Consumer, BackPressureStrategy)
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
static <I> UnicastProcessor<I>
create()
Creates a newUnicastProcessor
using a new unbounded queue.static <I> UnicastProcessor<I>
create(java.util.Queue<I> queue, java.lang.Runnable onTermination)
Creates a newUnicastProcessor
using the given queue.boolean
hasSubscriber()
Checks whether there is a subscriber listening for the emitted events.void
onComplete()
void
onError(java.lang.Throwable failure)
void
onNext(T t)
void
onSubscribe(org.reactivestreams.Subscription upstream)
void
request(long n)
SerializedProcessor<T,T>
serialized()
void
subscribe(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, onSubscribe, onSubscription, onTermination, paceDemand, runSubscriptionOn, select, skip, subscribe, subscribe, toHotStream, toUni, withContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
create
public static <I> UnicastProcessor<I> create()
Creates a newUnicastProcessor
using 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 newUnicastProcessor
using the given queue.- Type Parameters:
I
- the type of item- Parameters:
queue
- the queue, must not benull
onTermination
- the termination callback, can benull
- Returns:
- the unicast processor
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription upstream)
- Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<T>
-
subscribe
public void subscribe(MultiSubscriber<? super T> downstream)
- Overrides:
subscribe
in classAbstractMulti<T>
-
onError
public void onError(java.lang.Throwable failure)
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public void onComplete()
- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<T>
-
request
public void request(long n)
- Specified by:
request
in interfaceorg.reactivestreams.Subscription
-
cancel
public void cancel()
- Specified by:
cancel
in interfaceorg.reactivestreams.Subscription
-
hasSubscriber
public boolean hasSubscriber()
Checks whether there is a subscriber listening for the emitted events. Mostly for testing purpose.- Returns:
true
if there is a subscriber,false
otherwise
-
serialized
public SerializedProcessor<T,T> serialized()
-
-