Class UnicastProcessor<T>
- Type Parameters:
T- the input and output type
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Queue<T>,Processor<T,,T> Publisher<T>,Subscriber<T>,Subscription,CorePublisher<T>,CoreSubscriber<T>,Disposable,Fuseable,Fuseable.QueueSubscription<T>,Sinks.Many<T>,Scannable
Note: UnicastProcessor does not respect the actual subscriber's demand as it is described in Reactive Streams Spec. However, UnicastProcessor embraces configurable Queue internally which allows enabling backpressure support and preventing of consumer's overwhelming. Hence, interaction model between producers and UnicastProcessor will be PUSH only. In opposite, interaction model between UnicastProcessor and consumer will be PUSH-PULL as defined in Reactive Streams Spec. In the case when upstream's signals overflow the bound of internal Queue, UnicastProcessor will fail with signaling onError( reactor.core.Exceptions.OverflowException).
Note: The implementation keeps the order of signals. That means that in case of terminal signal (completion or error signals) it will be postponed until all of the previous signals has been consumed.
-
Nested Class Summary
Nested classes/interfaces inherited from interface reactor.core.Disposable
Disposable.Composite, Disposable.SwapNested classes/interfaces inherited from interface reactor.core.Fuseable
Fuseable.ConditionalSubscriber<T>, Fuseable.QueueSubscription<T>, Fuseable.ScalarCallable<T>, Fuseable.SynchronousSubscription<T>Nested classes/interfaces inherited from interface reactor.core.Scannable
Scannable.Attr<T> -
Field Summary
Fields inherited from interface reactor.core.Fuseable.QueueSubscription
NOT_SUPPORTED_MESSAGEFields inherited from interface reactor.core.Scannable
OPERATOR_NAME_UNRELATED_WORDS_PATTERN -
Constructor Summary
ConstructorsConstructorDescriptionUnicastProcessor(Queue<T> queue) Deprecated.UnicastProcessor(Queue<T> queue, Consumer<? super T> onOverflow, Disposable onTerminate) Deprecated.UnicastProcessor(Queue<T> queue, Disposable onTerminate) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionCoreSubscriber<? super T> actual()Deprecated.asFlux()Deprecated.Return aFluxview of this sink.voidcancel()Deprecated.voidclear()Deprecated.static <E> UnicastProcessor<E> create()Deprecated.useSinks.many().unicast().onBackpressureBuffer()(or the unsafe variant if you're sure about external synchronization).static <E> UnicastProcessor<E> Deprecated.useSinks.many().unicast().onBackpressureBuffer(queue)(or the unsafe variant if you're sure about external synchronization).static <E> UnicastProcessor<E> create(Queue<E> queue, Consumer<? super E> onOverflow, Disposable endcallback) Deprecated.useSinks.many().unicast().onBackpressureBuffer(queue, endCallback)(or the unsafe variant if you're sure about external synchronization).static <E> UnicastProcessor<E> create(Queue<E> queue, Disposable endcallback) Deprecated.useSinks.many().unicast().onBackpressureBuffer(queue, endCallback)(or the unsafe variant if you're sure about external synchronization).Deprecated.Request aContextfrom dependent components which can include downstream operators during subscribing or a terminalSubscriber.intDeprecated.Get how manySubscribersare currently subscribed to the sink.longDeprecated.Return the number of activeSubscriberor -1 if untracked.default voidemitComplete(Sinks.EmitFailureHandler failureHandler) A simplified attempt at completing via theSinks.Many.tryEmitComplete()API, generating anonCompletesignal.default voidemitError(Throwable error, Sinks.EmitFailureHandler failureHandler) A simplified attempt at failing the sequence via theSinks.Many.tryEmitError(Throwable)API, generating anonErrorsignal.voidemitNext(T value, Sinks.EmitFailureHandler failureHandler) Deprecated.A simplified attempt at emitting a non-null element via theSinks.Many.tryEmitNext(Object)API, generating anonNextsignal.intDeprecated.Return the processor buffer capacity if any orInteger.MAX_VALUEgetError()Deprecated.Current error if any, default to nullintDeprecated.The prefetch configuration of theFluxbooleanDeprecated.Return true if anySubscriberis actively subscribedinners()Deprecated.Return aStreamof referenced inners (flatmap, multicast etc)booleanDeprecated.Optionally return true when the resource or task is disposed.booleanisEmpty()Deprecated.protected booleanDeprecated.Return true ifFluxProcessor<T, T>booleanDeprecated.Has this upstream finished or "completed" / "failed" ?voidDeprecated.voidDeprecated.voidDeprecated.voidDeprecated.Implementors should initialize any state used bySubscriber.onNext(Object)before callingSubscription.request(long).poll()Deprecated.voidrequest(long n) Deprecated.intrequestFusion(int requestedMode) Deprecated.Request a specific fusion mode from this QueueSubscription.scanUnsafe(Scannable.Attr key) Deprecated.This method is used internally by components to define their key-value mappings in a single place.intsize()Deprecated.voidsubscribe(CoreSubscriber<? super T> actual) Deprecated.An internalPublisher.subscribe(Subscriber)that will bypassHooks.onLastOperator(Function)pointcut.Deprecated.Try to terminate the sequence successfully, generating anonCompletesignal.Deprecated.Try to fail the sequence, generating anonErrorsignal.tryEmitNext(T t) Deprecated.Try emitting a non-null element, generating anonNextsignal.Methods inherited from class reactor.core.publisher.FluxProcessor
dispose, hasCompleted, hasError, isSerialized, serialize, serializeAlways, sink, sink, switchOnNext, wrapMethods inherited from class reactor.core.publisher.Flux
all, any, as, blockFirst, blockFirst, blockLast, blockLast, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, bufferTimeout, bufferTimeout, bufferTimeout, bufferTimeout, bufferTimeout, bufferTimeout, bufferTimeout, bufferTimeout, bufferUntil, bufferUntil, bufferUntilChanged, bufferUntilChanged, bufferUntilChanged, bufferWhen, bufferWhen, bufferWhile, cache, cache, cache, cache, cache, cache, cancelOn, cast, checkpoint, checkpoint, checkpoint, collect, collect, collectList, collectMap, collectMap, collectMap, collectMultimap, collectMultimap, collectMultimap, collectSortedList, collectSortedList, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, concat, concat, concat, concat, concatDelayError, concatDelayError, concatDelayError, concatDelayError, concatMap, concatMap, concatMapDelayError, concatMapDelayError, concatMapDelayError, concatMapIterable, concatMapIterable, concatWith, concatWithValues, contextCapture, contextWrite, contextWrite, count, create, create, defaultIfEmpty, defer, deferContextual, delayElements, delayElements, delaySequence, delaySequence, delaySubscription, delaySubscription, delaySubscription, delayUntil, dematerialize, distinct, distinct, distinct, distinct, distinctUntilChanged, distinctUntilChanged, distinctUntilChanged, doAfterTerminate, doFinally, doFirst, doOnCancel, doOnComplete, doOnDiscard, doOnEach, doOnError, doOnError, doOnError, doOnNext, doOnRequest, doOnSubscribe, doOnTerminate, elapsed, elapsed, elementAt, elementAt, empty, error, error, error, expand, expand, expandDeep, expandDeep, filter, filterWhen, filterWhen, first, first, firstWithSignal, firstWithSignal, firstWithValue, firstWithValue, flatMap, flatMap, flatMap, flatMap, flatMapDelayError, flatMapIterable, flatMapIterable, flatMapSequential, flatMapSequential, flatMapSequential, flatMapSequentialDelayError, from, fromArray, fromIterable, fromStream, fromStream, generate, generate, generate, groupBy, groupBy, groupBy, groupBy, groupJoin, handle, hasElement, hasElements, hide, ignoreElements, index, index, interval, interval, interval, interval, join, just, just, last, last, limitRate, limitRate, limitRequest, log, log, log, log, log, log, map, mapNotNull, materialize, merge, merge, merge, merge, merge, merge, mergeComparing, mergeComparing, mergeComparing, mergeComparingDelayError, mergeComparingWith, mergeDelayError, mergeOrdered, mergeOrdered, mergeOrdered, mergeOrderedWith, mergePriority, mergePriority, mergePriority, mergePriorityDelayError, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequentialDelayError, mergeSequentialDelayError, mergeSequentialDelayError, mergeWith, metrics, name, never, next, ofType, onAssembly, onAssembly, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureDrop, onBackpressureDrop, onBackpressureError, onBackpressureLatest, onErrorComplete, onErrorComplete, onErrorComplete, onErrorContinue, onErrorContinue, onErrorContinue, onErrorMap, onErrorMap, onErrorMap, onErrorResume, onErrorResume, onErrorResume, onErrorReturn, onErrorReturn, onErrorReturn, onErrorStop, onTerminateDetach, or, parallel, parallel, parallel, publish, publish, publish, publish, publishNext, publishOn, publishOn, publishOn, push, push, range, reduce, reduce, reduceWith, repeat, repeat, repeat, repeat, repeatWhen, replay, replay, replay, replay, replay, replay, retry, retry, retryWhen, sample, sample, sampleFirst, sampleFirst, sampleTimeout, sampleTimeout, scan, scan, scanWith, share, shareNext, single, single, singleOrEmpty, skip, skip, skip, skipLast, skipUntil, skipUntilOther, skipWhile, sort, sort, startWith, startWith, startWith, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, subscribeOn, subscribeWith, switchIfEmpty, switchMap, switchMap, switchOnFirst, switchOnFirst, switchOnNext, switchOnNext, tag, take, take, take, take, takeLast, takeUntil, takeUntilOther, takeWhile, tap, tap, tap, then, then, thenEmpty, thenMany, timed, timed, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timestamp, timestamp, toIterable, toIterable, toIterable, toStream, toStream, toString, transform, transformDeferred, transformDeferredContextual, using, using, using, using, usingWhen, usingWhen, window, window, window, window, window, window, window, windowTimeout, windowTimeout, windowTimeout, windowTimeout, windowUntil, windowUntil, windowUntil, windowUntilChanged, windowUntilChanged, windowUntilChanged, windowWhen, windowWhile, windowWhile, withLatestFrom, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipWith, zipWith, zipWith, zipWith, zipWithIterable, zipWithIterableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArrayMethods inherited from interface reactor.core.Fuseable.QueueSubscription
add, addAll, contains, containsAll, element, iterator, offer, peek, remove, remove, removeAll, retainAll, toArray, toArrayMethods inherited from interface reactor.core.Scannable
actuals, isScanAvailable, name, parents, scan, scanOrDefault, stepName, steps, tags, tagsDeduplicated
-
Constructor Details
-
UnicastProcessor
Deprecated. -
UnicastProcessor
Deprecated. -
UnicastProcessor
@Deprecated public UnicastProcessor(Queue<T> queue, Consumer<? super T> onOverflow, Disposable onTerminate) Deprecated.
-
-
Method Details
-
create
Deprecated.useSinks.many().unicast().onBackpressureBuffer()(or the unsafe variant if you're sure about external synchronization). To be removed in 3.5.Create a newUnicastProcessorthat will buffer on an internal queue in an unbounded fashion.- Type Parameters:
E- the relayed type- Returns:
- a unicast
FluxProcessor
-
create
Deprecated.useSinks.many().unicast().onBackpressureBuffer(queue)(or the unsafe variant if you're sure about external synchronization). To be removed in 3.5.Create a newUnicastProcessorthat will buffer on a provided queue in an unbounded fashion.- Type Parameters:
E- the relayed type- Parameters:
queue- the buffering queue- Returns:
- a unicast
FluxProcessor
-
create
Deprecated.useSinks.many().unicast().onBackpressureBuffer(queue, endCallback)(or the unsafe variant if you're sure about external synchronization). To be removed in 3.5.Create a newUnicastProcessorthat will buffer on a provided queue in an unbounded fashion.- Type Parameters:
E- the relayed type- Parameters:
queue- the buffering queueendcallback- called on any terminal signal- Returns:
- a unicast
FluxProcessor
-
create
@Deprecated public static <E> UnicastProcessor<E> create(Queue<E> queue, Consumer<? super E> onOverflow, Disposable endcallback) Deprecated.useSinks.many().unicast().onBackpressureBuffer(queue, endCallback)(or the unsafe variant if you're sure about external synchronization). TheonOverflowcallback is not supported anymore. To be removed in 3.5.Create a newUnicastProcessorthat will buffer on a provided queue in an unbounded fashion.- Type Parameters:
E- the relayed type- Parameters:
queue- the buffering queueonOverflow- called when queue.offer return false and unicastProcessor is about to emit onError.endcallback- called on any terminal signal- Returns:
- a unicast
FluxProcessor
-
getBufferSize
public int getBufferSize()Deprecated.Description copied from class:FluxProcessorReturn the processor buffer capacity if any orInteger.MAX_VALUE- Overrides:
getBufferSizein classFluxProcessor<T,T> - Returns:
- processor buffer capacity if any or
Integer.MAX_VALUE
-
inners
Deprecated.Description copied from interface:ScannableReturn aStreamof referenced inners (flatmap, multicast etc) -
scanUnsafe
Deprecated.Description copied from interface:ScannableThis method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of theScannable.Attrkey, implementors should take care to return values of the correct type, and return null if no specific value is available.For public consumption of attributes, prefer using
Scannable.scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.- Specified by:
scanUnsafein interfaceScannable- Overrides:
scanUnsafein classFluxProcessor<T,T> - Parameters:
key- aScannable.Attrto resolve for the component.- Returns:
- the value associated to the key for that specific component, or null if none.
-
onComplete
public void onComplete()Deprecated.- Specified by:
onCompletein interfaceSubscriber<T>
-
tryEmitComplete
Deprecated.Description copied from interface:Sinks.ManyTry to terminate the sequence successfully, generating anonCompletesignal. The result of the attempt is represented as anSinks.EmitResult, which possibly indicates error cases.See the list of failure
Sinks.EmitResultinSinks.Many.emitComplete(EmitFailureHandler)javadoc for an example of how each of these can be dealt with, to decide if the emit API would be a good enough fit instead.- Specified by:
tryEmitCompletein interfaceSinks.Many<T>- Returns:
- an
Sinks.EmitResult, which should be checked to distinguish different possible failures - See Also:
-
onError
Deprecated.- Specified by:
onErrorin interfaceSubscriber<T>
-
tryEmitError
Deprecated.Description copied from interface:Sinks.ManyTry to fail the sequence, generating anonErrorsignal. The result of the attempt is represented as anSinks.EmitResult, which possibly indicates error cases.See the list of failure
Sinks.EmitResultinSinks.Many.emitError(Throwable, EmitFailureHandler)javadoc for an example of how each of these can be dealt with, to decide if the emit API would be a good enough fit instead.- Specified by:
tryEmitErrorin interfaceSinks.Many<T>- Parameters:
t- the exception to signal, not null- Returns:
- an
Sinks.EmitResult, which should be checked to distinguish different possible failures - See Also:
-
onNext
Deprecated.- Specified by:
onNextin interfaceSubscriber<T>
-
emitNext
Deprecated.Description copied from interface:Sinks.ManyA simplified attempt at emitting a non-null element via theSinks.Many.tryEmitNext(Object)API, generating anonNextsignal. If the result of the attempt is not asuccess, implementations SHOULD retry theSinks.Many.tryEmitNext(Object)call IF the providedSinks.EmitFailureHandlerreturnstrue. Otherwise, failures are dealt with in a predefined way that might depend on the actual sink implementation (see below for the vanilla reactor-core behavior).Generally,
Sinks.Many.tryEmitNext(Object)is preferable since it allows a custom handling of error cases, although this implies checking the returnedSinks.EmitResultand correctly acting on it. This API is intended as a good default for convenience.When the
Sinks.EmitResultis not a success, vanilla reactor-core operators have the following behavior:-
Sinks.EmitResult.FAIL_ZERO_SUBSCRIBER: no particular handling. should ideally discard the value but at that point there's noSubscriberfrom which to get a contextual discard handler. -
Sinks.EmitResult.FAIL_OVERFLOW: discard the value (Operators.onDiscard(Object, Context)) then callSinks.Many.emitError(Throwable, Sinks.EmitFailureHandler)with aExceptions.failWithOverflow(String)exception. -
Sinks.EmitResult.FAIL_CANCELLED: discard the value (Operators.onDiscard(Object, Context)). -
Sinks.EmitResult.FAIL_TERMINATED: drop the value (Operators.onNextDropped(Object, Context)). -
Sinks.EmitResult.FAIL_NON_SERIALIZED: throw anSinks.EmissionExceptionmentioning RS spec rule 1.3. Note thatSinks.unsafe()never trigger this result. It would be possible for anSinks.EmitFailureHandlerto busy-loop and optimistically wait for the contention to disappear to avoid this case for safe sinks...
Might throw an unchecked exception as a last resort (eg. in case of a fatal error downstream which cannot be propagated to any asynchronous handler, a bubbling exception, a
Sinks.EmitResult.FAIL_NON_SERIALIZEDas described above, ...).- Specified by:
emitNextin interfaceSinks.Many<T>- Parameters:
value- the value to emit, not nullfailureHandler- the failure handler that allows retrying failedSinks.EmitResult.- See Also:
-
-
tryEmitNext
Deprecated.Description copied from interface:Sinks.ManyTry emitting a non-null element, generating anonNextsignal. The result of the attempt is represented as anSinks.EmitResult, which possibly indicates error cases.See the list of failure
Sinks.EmitResultinSinks.Many.emitNext(Object, EmitFailureHandler)javadoc for an example of how each of these can be dealt with, to decide if the emit API would be a good enough fit instead.Might throw an unchecked exception as a last resort (eg. in case of a fatal error downstream which cannot be propagated to any asynchronous handler, a bubbling exception, ...).
- Specified by:
tryEmitNextin interfaceSinks.Many<T>- Parameters:
t- the value to emit, not null- Returns:
- an
Sinks.EmitResult, which should be checked to distinguish different possible failures - See Also:
-
currentSubscriberCount
public int currentSubscriberCount()Deprecated.Description copied from interface:Sinks.ManyGet how manySubscribersare currently subscribed to the sink.This is a best effort peek at the sink state, and a subsequent attempt at emitting to the sink might still return
Sinks.EmitResult.FAIL_ZERO_SUBSCRIBERwhere relevant. (generally inSinks.Many.tryEmitNext(Object)). Request (and lack thereof) isn't taken into account, all registered subscribers are counted.- Specified by:
currentSubscriberCountin interfaceSinks.Many<T>- Returns:
- the number of subscribers at the time of invocation
-
asFlux
Deprecated.Description copied from interface:Sinks.ManyReturn aFluxview of this sink. Every call returns the same instance.- Specified by:
asFluxin interfaceSinks.Many<T>- Returns:
- the
Fluxview associated to thisSinks.Many
-
isIdentityProcessor
protected boolean isIdentityProcessor()Deprecated.Description copied from class:FluxProcessorReturn true ifFluxProcessor<T, T>- Overrides:
isIdentityProcessorin classFluxProcessor<T,T> - Returns:
- true if
FluxProcessor<T, T>
-
onSubscribe
Deprecated.Description copied from interface:CoreSubscriberImplementors should initialize any state used bySubscriber.onNext(Object)before callingSubscription.request(long). Should furtheronNextrelated state modification occur, thread-safety will be required.Note that an invalid request
<= 0will not produce an onError and will simply be ignored or reported through a debug-enabledLogger.- Specified by:
onSubscribein interfaceCoreSubscriber<T>- Specified by:
onSubscribein interfaceSubscriber<T>
-
getPrefetch
public int getPrefetch()Deprecated.Description copied from class:FluxThe prefetch configuration of theFlux- Overrides:
getPrefetchin classFlux<T>- Returns:
- the prefetch configuration of the
Flux, -1 if unspecified
-
currentContext
Deprecated.Description copied from interface:CoreSubscriberRequest aContextfrom dependent components which can include downstream operators during subscribing or a terminalSubscriber.- Specified by:
currentContextin interfaceCoreSubscriber<T>- Overrides:
currentContextin classFluxProcessor<T,T> - Returns:
- a resolved context or
Context.empty()
-
subscribe
Deprecated.Description copied from class:FluxAn internalPublisher.subscribe(Subscriber)that will bypassHooks.onLastOperator(Function)pointcut.In addition to behave as expected by
Publisher.subscribe(Subscriber)in a controlled manner, it supports direct subscribe-timeContextpassing.- Specified by:
subscribein interfaceCorePublisher<T>- Specified by:
subscribein classFlux<T>- Parameters:
actual- theSubscriberinterested into the published sequence- See Also:
-
request
public void request(long n) Deprecated.- Specified by:
requestin interfaceSubscription
-
cancel
public void cancel()Deprecated.- Specified by:
cancelin interfaceSubscription
-
poll
Deprecated. -
size
public int size()Deprecated.- Specified by:
sizein interfaceCollection<T>
-
isEmpty
public boolean isEmpty()Deprecated.- Specified by:
isEmptyin interfaceCollection<T>
-
clear
public void clear()Deprecated.- Specified by:
clearin interfaceCollection<T>
-
requestFusion
public int requestFusion(int requestedMode) Deprecated.Description copied from interface:Fuseable.QueueSubscriptionRequest a specific fusion mode from this QueueSubscription.One should request either SYNC, ASYNC or ANY modes (never NONE) and the implementor should return NONE, SYNC or ASYNC (never ANY).
For example, if a source supports only ASYNC fusion but the intermediate operator supports only SYNC fuseable sources, the operator may request SYNC fusion and the source can reject it via NONE, thus the operator can return NONE as well to downstream and the fusion doesn't happen.
- Specified by:
requestFusionin interfaceFuseable.QueueSubscription<T>- Parameters:
requestedMode- the mode requested by the intermediate operator- Returns:
- the actual fusion mode activated
-
isDisposed
public boolean isDisposed()Deprecated.Description copied from interface:DisposableOptionally return true when the resource or task is disposed.Implementations are not required to track disposition and as such may never return true even when disposed. However, they MUST only return true when there's a guarantee the resource or task is disposed.
- Specified by:
isDisposedin interfaceDisposable- Returns:
- true when there's a guarantee the resource or task is disposed.
-
isTerminated
public boolean isTerminated()Deprecated.Description copied from class:FluxProcessorHas this upstream finished or "completed" / "failed" ?- Overrides:
isTerminatedin classFluxProcessor<T,T> - Returns:
- has this upstream finished or "completed" / "failed" ?
-
getError
Deprecated.Description copied from class:FluxProcessorCurrent error if any, default to null- Overrides:
getErrorin classFluxProcessor<T,T> - Returns:
- Current error if any, default to null
-
actual
Deprecated. -
downstreamCount
public long downstreamCount()Deprecated.Description copied from class:FluxProcessorReturn the number of activeSubscriberor -1 if untracked.- Overrides:
downstreamCountin classFluxProcessor<T,T> - Returns:
- the number of active
Subscriberor -1 if untracked
-
hasDownstreams
public boolean hasDownstreams()Deprecated.Description copied from class:FluxProcessorReturn true if anySubscriberis actively subscribed- Overrides:
hasDownstreamsin classFluxProcessor<T,T> - Returns:
- true if any
Subscriberis actively subscribed
-
emitComplete
Description copied from interface:Sinks.ManyA simplified attempt at completing via theSinks.Many.tryEmitComplete()API, generating anonCompletesignal. If the result of the attempt is not asuccess, implementations SHOULD retry theSinks.Many.tryEmitComplete()call IF the providedSinks.EmitFailureHandlerreturnstrue. Otherwise, failures are dealt with in a predefined way that might depend on the actual sink implementation (see below for the vanilla reactor-core behavior).Generally,
Sinks.Many.tryEmitComplete()is preferable since it allows a custom handling of error cases, although this implies checking the returnedSinks.EmitResultand correctly acting on it. This API is intended as a good default for convenience.When the
Sinks.EmitResultis not a success, vanilla reactor-core operators have the following behavior:-
Sinks.EmitResult.FAIL_OVERFLOW: irrelevant as onComplete is not driven by backpressure. -
Sinks.EmitResult.FAIL_ZERO_SUBSCRIBER: the completion can be ignored since nobody is listening. Note that most vanilla reactor sinks never trigger this result for onComplete, replaying the terminal signal to later subscribers instead (to the exception ofSinks.UnicastSpec.onBackpressureError()). -
Sinks.EmitResult.FAIL_CANCELLED: the completion can be ignored since nobody is interested. -
Sinks.EmitResult.FAIL_TERMINATED: the extra completion is basically ignored since there was a previous termination signal, but there is nothing interesting to log. -
Sinks.EmitResult.FAIL_NON_SERIALIZED: throw anSinks.EmissionExceptionmentioning RS spec rule 1.3. Note thatSinks.unsafe()never trigger this result. It would be possible for anSinks.EmitFailureHandlerto busy-loop and optimistically wait for the contention to disappear to avoid this case in safe sinks...
Might throw an unchecked exception as a last resort (eg. in case of a fatal error downstream which cannot be propagated to any asynchronous handler, a bubbling exception, a
Sinks.EmitResult.FAIL_NON_SERIALIZEDas described above, ...).- Specified by:
emitCompletein interfaceSinks.Many<T>- Parameters:
failureHandler- the failure handler that allows retrying failedSinks.EmitResult.- See Also:
-
-
emitError
Description copied from interface:Sinks.ManyA simplified attempt at failing the sequence via theSinks.Many.tryEmitError(Throwable)API, generating anonErrorsignal. If the result of the attempt is not asuccess, implementations SHOULD retry theSinks.Many.tryEmitError(Throwable)call IF the providedSinks.EmitFailureHandlerreturnstrue. Otherwise, failures are dealt with in a predefined way that might depend on the actual sink implementation (see below for the vanilla reactor-core behavior).Generally,
Sinks.Many.tryEmitError(Throwable)is preferable since it allows a custom handling of error cases, although this implies checking the returnedSinks.EmitResultand correctly acting on it. This API is intended as a good default for convenience.When the
Sinks.EmitResultis not a success, vanilla reactor-core operators have the following behavior:-
Sinks.EmitResult.FAIL_OVERFLOW: irrelevant as onError is not driven by backpressure. -
Sinks.EmitResult.FAIL_ZERO_SUBSCRIBER: the error is ignored since nobody is listening. Note that most vanilla reactor sinks never trigger this result for onError, replaying the terminal signal to later subscribers instead (to the exception ofSinks.UnicastSpec.onBackpressureError()). -
Sinks.EmitResult.FAIL_CANCELLED: the error can be ignored since nobody is interested. -
Sinks.EmitResult.FAIL_TERMINATED: the error unexpectedly follows another terminal signal, so it is dropped viaOperators.onErrorDropped(Throwable, Context). -
Sinks.EmitResult.FAIL_NON_SERIALIZED: throw anSinks.EmissionExceptionmentioning RS spec rule 1.3. Note thatSinks.unsafe()never trigger this result. It would be possible for anSinks.EmitFailureHandlerto busy-loop and optimistically wait for the contention to disappear to avoid this case in safe sinks...
Might throw an unchecked exception as a last resort (eg. in case of a fatal error downstream which cannot be propagated to any asynchronous handler, a bubbling exception, a
Sinks.EmitResult.FAIL_NON_SERIALIZEDas described above, ...).- Specified by:
emitErrorin interfaceSinks.Many<T>- Parameters:
error- the exception to signal, not nullfailureHandler- the failure handler that allows retrying failedSinks.EmitResult.- See Also:
-
-
Sinksthrough variations underSinks.many().unicast().