Top Description Fields Constructors Methods
reactor.core.publisher

public abstract Class MonoProcessor<O>

extends Mono<O>
implements Processor<O, O>, CoreSubscriber<O>, Disposable, Subscription, Scannable
Class Inheritance
All Implemented Interfaces
reactor.core.Scannable, org.reactivestreams.Subscription, reactor.core.Disposable, reactor.core.CoreSubscriber, org.reactivestreams.Subscriber, org.reactivestreams.Processor, org.reactivestreams.Publisher
Known Direct Subclasses
reactor.core.publisher.NextProcessor
Annotations
@Deprecated
Type Parameters
<O>
the type of the value that will be made available
Imports
java.time.Duration, java.util.concurrent.CancellationException, java.util.stream.Stream, org.reactivestreams.Processor, .Subscriber, .Subscription, reactor.core.CoreSubscriber, .Disposable, .Scannable, reactor.util.annotation.Nullable, reactor.util.context.Context

Deprecated

Processors will be removed in 3.5. Prefer using Sinks.One or Sinks.Empty instead, or see https://github.com/reactor/reactor-core/issues/2431 for alternatives

A MonoProcessor is a Processor that is also a Mono.

Implementations might implements stateful semantics, allowing multiple subscriptions. Once a MonoProcessor has been resolved, implementations may also replay cached signals to newer subscribers.

Despite having default implementations, most methods should be reimplemented with meaningful semantics relevant to concrete child classes.

Author
Stephane Maldini

Field Summary

Inherited from reactor.core.publisher.Mono:
EQUALS_BIPREDICATE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public O

Returns:

the value of this MonoProcessor
block
()

Overrides reactor.core.publisher.Mono.block.

Block the calling thread indefinitely, waiting for the completion of this MonoProcessor.
public O

Returns:

the value of this MonoProcessor or null if the timeout is reached and the MonoProcessor has not completed
block
(Duration
the timeout value as a Duration
timeout
)

Overrides reactor.core.publisher.Mono.block.

Block the calling thread for the specified time, waiting for the completion of this MonoProcessor.
public void
cancel()

Implements org.reactivestreams.Subscription.cancel.

Deprecated the MonoProcessor will cease to implement Subscription in 3.5
Request the Publisher to stop sending data and clean up resources.
public static <
type of the expected value
T
>
MonoProcessor<T>

Returns:

A MonoProcessor.
create
()

Deprecated Use Sinks#one(), to be removed in 3.5
Create a MonoProcessor that will eagerly request 1 on onSubscribe(Subscription), cache and emit the eventual result for 1 or N subscribers.
public Context
currentContext()

Overrides default reactor.core.CoreSubscriber.currentContext.

Request a Context from dependent components which can include downstream operators during subscribing or a terminal org.reactivestreams.Subscriber.
public void
dispose()

Implements reactor.core.Disposable.dispose.

Cancel or dispose the underlying task or resource.
public long

Returns:

the number of active Subscriber or -1 if untracked
downstreamCount
()

Return the number of active Subscriber or -1 if untracked.

public Throwable

Returns:

the produced Throwable error if any or null
getError
()

Return the produced Throwable error if any or null

public final boolean

Returns:

true if any Subscriber is actively subscribed
hasDownstreams
()

Return true if any Subscriber is actively subscribed

public Stream<? extends Scannable>
inners()

Overrides default reactor.core.Scannable.inners.

Return a Stream of referenced inners (flatmap, multicast etc)
public boolean

Returns:

true if this MonoProcessor is cancelled, false otherwise.
isCancelled
()

Deprecated the MonoProcessor will cease to implement Subscription and this method will be removed in 3.5
Indicates whether this MonoProcessor has been interrupted via cancellation.
public boolean
isDisposed()

Overrides default reactor.core.Disposable.isDisposed.

Optionally return true when the resource or task is disposed.
public final boolean

Returns:

true if this MonoProcessor was completed with an error, false otherwise.
isError
()

Indicates whether this MonoProcessor has been completed with an error.

public final boolean

Returns:

true if this MonoProcessor is successful, false otherwise.
isSuccess
()

Indicates whether this MonoProcessor has been successfully completed a value.

public boolean

Returns:

true if this MonoProcessor is successful, false otherwise.
isTerminated
()

Indicates whether this MonoProcessor has been terminated by the source producer with a success or an error.

public O

Returns:

the value that completed the MonoProcessor, or null if it has not been completed
peek
()

Deprecated this method is discouraged, consider peeking into a MonoProcessor by turning it into a CompletableFuture
Returns the value that completed this MonoProcessor.
public void
request(long
the request amount
n
)

Implements org.reactivestreams.Subscription.request.

Deprecated the MonoProcessor will cease to implement Subscription in 3.5
No events will be sent by a Publisher until demand is signaled via this method.
public Object
scanUnsafe(Scannable.Attr<T>
a Attr to resolve for the component.
key
)

Implements reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place.
Inherited from reactor.core.publisher.Mono:
andasblockOptionalblockOptionalcachecachecachecachecachecacheInvalidateIfcacheInvalidateWhencacheInvalidateWhencancelOncastcheckpointcheckpointcheckpointconcatWithcontextCapturecontextWritecontextWritecreatedefaultIfEmptydeferdeferContextualdelaydelaydelayElementdelayElementdelaySubscriptiondelaySubscriptiondelaySubscriptiondelayUntildematerializedoAfterTerminatedoFinallydoFirstdoOnCanceldoOnDiscarddoOnEachdoOnErrordoOnErrordoOnErrordoOnNextdoOnRequestdoOnSignaldoOnSubscribedoOnSuccessdoOnTerminalSignaldoOnTerminateelapsedelapsedemptyemptyequalsBiPredicateerrorerrorexpandexpandexpandDeepexpandDeepfilterfilterWhenfirstfirstfirstWithSignalfirstWithSignalfirstWithValuefirstWithValueflatMapflatMapIterableflatMapManyflatMapManyfluxfromfromCallablefromCompletionStagefromCompletionStagefromDirectfromFuturefromFuturefromFuturefromFuturefromRunnablefromSupplierhandlehasElementhideignoreElementignoreElementsjustjustOrEmptyjustOrEmptyloglogloglogloglogmapmapNotNullmaterializemergeWithmetricsnameneverofTypeonAssemblyonErrorCompleteonErrorCompleteonErrorCompleteonErrorContinueonErrorContinueonErrorContinueonErrorMaponErrorMaponErrorMaponErrorResumeonErrorResumeonErrorResumeonErrorReturnonErrorReturnonErrorReturnonErrorStoponTerminateDetachorpublishpublishOnrepeatrepeatrepeatrepeatrepeatWhenrepeatWhenEmptyrepeatWhenEmptyretryretryretryWhensequenceEqualsequenceEqualsequenceEqualsharesinglesingleOptionalsubscribesubscribesubscribesubscribesubscribesubscribesubscribesubscribesubscribeOnsubscribeWithswitchIfEmptytagtaketaketakeUntilOthertaptaptapthenthenthenEmptythenManythenReturntimedtimedtimeouttimeouttimeouttimeouttimeouttimeouttimestamptimestamptoFuturetoStringtransformtransformDeferredtransformDeferredContextualusingusingusingWhenusingWhenwhenwhenwhenDelayErrorwhenDelayErrorwrapzipzipzipzipzipzipzipzipzipzipzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipWhenzipWhenzipWithzipWith

Constructor Detail

MonoProcessorback to summary
public MonoProcessor()

Method Detail

blockback to summary
public O block()

Overrides reactor.core.publisher.Mono.block.

Block the calling thread indefinitely, waiting for the completion of this MonoProcessor. If the MonoProcessor is completed with an error a RuntimeException that wraps the error is thrown.

Returns:O

the value of this MonoProcessor

Annotations
@Override
@Nullable
blockback to summary
public O block(Duration timeout)

Overrides reactor.core.publisher.Mono.block.

Block the calling thread for the specified time, waiting for the completion of this MonoProcessor. If the MonoProcessor is completed with an error a RuntimeException that wraps the error is thrown.

Parameters
timeout:Duration

the timeout value as a Duration

Returns:O

the value of this MonoProcessor or null if the timeout is reached and the MonoProcessor has not completed

Annotations
@Override
@Nullable
cancelback to summary
public void cancel()

Implements org.reactivestreams.Subscription.cancel.

Doc from org.reactivestreams.Subscription.cancel.

Deprecated

the MonoProcessor will cease to implement Subscription in 3.5

Request the Publisher to stop sending data and clean up resources.

Data may still be sent to meet previously signalled demand after calling cancel.

Annotations
@Override
@Deprecated
createback to summary
public static <T> MonoProcessor<T> create()

Deprecated

Use Sinks#one(), to be removed in 3.5

Create a MonoProcessor that will eagerly request 1 on onSubscribe(Subscription), cache and emit the eventual result for 1 or N subscribers.

Parameters
<T>
type of the expected value
Returns:MonoProcessor<T>

A MonoProcessor.

Annotations
@Deprecated
currentContextback to summary
public Context currentContext()

Overrides default reactor.core.CoreSubscriber.currentContext.

Doc from reactor.core.CoreSubscriber.currentContext.

Request a Context from dependent components which can include downstream operators during subscribing or a terminal org.reactivestreams.Subscriber.

Returns:Context

a resolved context or Context#empty()

Annotations
@Override
disposeback to summary
public void dispose()

Implements reactor.core.Disposable.dispose.

Doc from reactor.core.Disposable.dispose.

Cancel or dispose the underlying task or resource.

Implementations are required to make this method idempotent.

Annotations
@Override
downstreamCountback to summary
public long downstreamCount()

Return the number of active Subscriber or -1 if untracked.

Returns:long

the number of active Subscriber or -1 if untracked

getErrorback to summary
public Throwable getError()

Return the produced Throwable error if any or null

Returns:Throwable

the produced Throwable error if any or null

Annotations
@Nullable
hasDownstreamsback to summary
public final boolean hasDownstreams()

Return true if any Subscriber is actively subscribed

Returns:boolean

true if any Subscriber is actively subscribed

innersback to summary
public Stream<? extends Scannable> inners()

Overrides default reactor.core.Scannable.inners.

Doc from reactor.core.Scannable.inners.

Return a Stream of referenced inners (flatmap, multicast etc)

Returns:Stream<? extends Scannable>

a Stream of referenced inners (flatmap, multicast etc)

Annotations
@Override
isCancelledback to summary
public boolean isCancelled()

Deprecated

the MonoProcessor will cease to implement Subscription and this method will be removed in 3.5

Indicates whether this MonoProcessor has been interrupted via cancellation.

Returns:boolean

true if this MonoProcessor is cancelled, false otherwise.

Annotations
@Deprecated
isDisposedback to summary
public boolean isDisposed()

Overrides default reactor.core.Disposable.isDisposed.

Doc from reactor.core.Disposable.isDisposed.

Optionally 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.

Returns:boolean

true when there's a guarantee the resource or task is disposed.

Annotations
@Override
isErrorback to summary
public final boolean isError()

Indicates whether this MonoProcessor has been completed with an error.

Returns:boolean

true if this MonoProcessor was completed with an error, false otherwise.

isSuccessback to summary
public final boolean isSuccess()

Indicates whether this MonoProcessor has been successfully completed a value.

Returns:boolean

true if this MonoProcessor is successful, false otherwise.

isTerminatedback to summary
public boolean isTerminated()

Indicates whether this MonoProcessor has been terminated by the source producer with a success or an error.

Returns:boolean

true if this MonoProcessor is successful, false otherwise.

peekback to summary
public O peek()

Deprecated

this method is discouraged, consider peeking into a MonoProcessor by turning it into a CompletableFuture

Returns the value that completed this MonoProcessor. Returns null if the MonoProcessor has not been completed. If the MonoProcessor is completed with an error a RuntimeException that wraps the error is thrown.

Returns:O

the value that completed the MonoProcessor, or null if it has not been completed

Annotations
@Nullable
@Deprecated
Exceptions
RuntimeException:
if the MonoProcessor was completed with an error
requestback to summary
public void request(long n)

Implements org.reactivestreams.Subscription.request.

Doc from org.reactivestreams.Subscription.request.

Deprecated

the MonoProcessor will cease to implement Subscription in 3.5

No events will be sent by a Publisher until demand is signaled via this method.

It can be called however often and whenever needed—but if the outstanding cumulative demand ever becomes Long.MAX_VALUE or more, it may be treated by the Publisher as "effectively unbounded".

Whatever has been requested can be sent by the Publisher so only signal demand for what can be safely handled.

A Publisher can send less than is requested if the stream ends but then must emit either Subscriber#onError(Throwable) or Subscriber#onComplete().

Parameters
n:long

the request amount

Annotations
@Override
@Deprecated
scanUnsafeback to summary
public Object scanUnsafe(Scannable.Attr<T> key)

Implements reactor.core.Scannable.scanUnsafe.

Doc from reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of the Attr key, 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 scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.

Parameters
key:Scannable.Attr<T>

a Attr to resolve for the component.

Returns:Object

the value associated to the key for that specific component, or null if none.

Annotations
@Override
@Nullable