Top Description Inners Methods
reactor.core.publisher

public Interface FluxSink<T>

Known Direct Implementers
reactor.core.publisher.FluxCreate.SerializedFluxSink, reactor.core.publisher.FluxCreate.SerializeOnRequestSink, reactor.core.publisher.FluxCreate.BaseSink
Type Parameters
<T>
the value type
Imports
java.util.function.Function, .LongConsumer, org.reactivestreams.Subscriber, .Subscription, reactor.core.CoreSubscriber, .Disposable, reactor.util.context.Context, .ContextView

Wrapper API around a downstream Subscriber for emitting any number of next signals followed by zero or one onError/onComplete.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
FluxSink.OverflowStrategy

Enumeration for backpressure handling.

Method Summary

Modifier and TypeMethod and Description
public void
complete()

Terminate the sequence successfully, generating an onComplete signal.

public default ContextView

Returns:

the current subscriber ContextView.
contextView
()

Return the current subscriber's context as a ContextView for inspection.

public Context
currentContext()

Deprecated To be removed in 3.6.0 at the earliest. Prefer using #contextView() instead.
Return the current subscriber Context.
public void
error(Throwable
the exception to signal, not null
e
)

Fail the sequence, generating an onError signal.

public boolean

Returns:

true if the downstream cancelled the sequence
isCancelled
()

Returns true if the downstream cancelled the sequence.

public FluxSink<T>

Returns:

this sink for chaining further signals
next
(T
the value to emit, not null
t
)

Emit a non-null element, generating an onNext signal.

public FluxSink<T>

Returns:

the FluxSink with a cancellation callback
onCancel
(Disposable
the Disposable to use as a callback
d
)

Attach a Disposable as a callback for when this FluxSink is cancelled.

public FluxSink<T>

Returns:

the FluxSink with a callback invoked on any terminal signal or on cancellation
onDispose
(Disposable
the Disposable to use as a callback
d
)

Attach a Disposable as a callback for when this FluxSink is effectively disposed, that is it cannot be used anymore.

public FluxSink<T>

Returns:

FluxSink with a consumer that is notified of requests
onRequest
(LongConsumer
the consumer to invoke on each request
consumer
)

Attaches a LongConsumer to this FluxSink that will be notified of any request to this sink.

public long

Returns:

the current outstanding request amount
requestedFromDownstream
()

The current outstanding request amount.

Method Detail

completeback to summary
public void complete()

Terminate the sequence successfully, generating an onComplete signal.

See Also
Subscriber#onComplete()
contextViewback to summary
public default ContextView contextView()

Return the current subscriber's context as a ContextView for inspection.

Context can be enriched downstream via Flux#contextWrite(Function) operator or directly by a child subscriber overriding CoreSubscriber#currentContext().

Returns:ContextView

the current subscriber ContextView.

currentContextback to summary
public Context currentContext()

Deprecated

To be removed in 3.6.0 at the earliest. Prefer using #contextView() instead.

Return the current subscriber Context.

Context can be enriched via Flux#contextWrite(Function) operator or directly by a child subscriber overriding CoreSubscriber#currentContext()

Annotations
@Deprecated
errorback to summary
public void error(Throwable e)

Fail the sequence, generating an onError signal.

Parameters
e:Throwable

the exception to signal, not null

See Also
Subscriber#onError(Throwable)
isCancelledback to summary
public boolean isCancelled()

Returns true if the downstream cancelled the sequence.

Returns:boolean

true if the downstream cancelled the sequence

nextback to summary
public FluxSink<T> next(T t)

Emit a non-null element, generating an onNext signal.

Might throw an unchecked exception in case of a fatal error downstream which cannot be propagated to any asynchronous handler (aka a bubbling exception).

Parameters
t:T

the value to emit, not null

Returns:FluxSink<T>

this sink for chaining further signals

onCancelback to summary
public FluxSink<T> onCancel(Disposable d)

Attach a Disposable as a callback for when this FluxSink is cancelled. At most one callback can be registered, and subsequent calls to this method will result in the immediate disposal of the extraneous Disposable.

The callback is only relevant when the downstream Subscription is cancelled.

Parameters
d:Disposable

the Disposable to use as a callback

Returns:FluxSink<T>

the FluxSink with a cancellation callback

See Also
onDispose(Disposable) for a callback that covers cancellation AND terminal signals
onDisposeback to summary
public FluxSink<T> onDispose(Disposable d)

Attach a Disposable as a callback for when this FluxSink is effectively disposed, that is it cannot be used anymore. This includes both having played terminal signals (onComplete, onError) and having been cancelled (see onCancel(Disposable)). At most one callback can be registered, and subsequent calls to this method will result in the immediate disposal of the extraneous Disposable.

Note that the "dispose" term is used from the perspective of the sink. Not to be confused with Flux#subscribe()'s Disposable#dispose() method, which maps to disposing the Subscription (effectively, a Subscription#cancel() signal).

Parameters
d:Disposable

the Disposable to use as a callback

Returns:FluxSink<T>

the FluxSink with a callback invoked on any terminal signal or on cancellation

See Also
onCancel(Disposable) for a cancellation-only callback
onRequestback to summary
public FluxSink<T> onRequest(LongConsumer consumer)

Attaches a LongConsumer to this FluxSink that will be notified of any request to this sink.

For push/pull sinks created using Flux#create(java.util.function.Consumer) or Flux#create(java.util.function.Consumer, FluxSink.OverflowStrategy), the consumer is invoked for every request to enable a hybrid backpressure-enabled push/pull model.

Note

in case of multiple Subscription#request happening concurrently to this method, the first consumer invocation may process accumulated demand instead of being called multiple times.

When bridging with asynchronous listener-based APIs, the onRequest callback may be used to request more data from source if required and to manage backpressure by delivering data to sink only when requests are pending.

For push-only sinks created using Flux#push(java.util.function.Consumer) or Flux#push(java.util.function.Consumer, FluxSink.OverflowStrategy), the consumer is invoked with an initial request of Long.MAX_VALUE when this method is invoked.

Parameters
consumer:LongConsumer

the consumer to invoke on each request

Returns:FluxSink<T>

FluxSink with a consumer that is notified of requests

requestedFromDownstreamback to summary
public long requestedFromDownstream()

The current outstanding request amount.

Returns:long

the current outstanding request amount

reactor.core.publisher back to summary

public final Enum FluxSink.OverflowStrategy

extends Enum<FluxSink.OverflowStrategy>
Class Inheritance

Enumeration for backpressure handling.

Field Summary

Modifier and TypeField and Description
public static final FluxSink.OverflowStrategy
BUFFER

Buffer all signals if the downstream can't keep up.

public static final FluxSink.OverflowStrategy
DROP

Drop the incoming signal if the downstream is not ready to receive it.

public static final FluxSink.OverflowStrategy
ERROR

Signal an IllegalStateException when the downstream can't keep up

public static final FluxSink.OverflowStrategy
IGNORE

Completely ignore downstream backpressure requests.

public static final FluxSink.OverflowStrategy
LATEST

Downstream will get only the latest signals from upstream.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static FluxSink.OverflowStrategy
public static FluxSink.OverflowStrategy[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BUFFERback to summary
public static final FluxSink.OverflowStrategy BUFFER

Buffer all signals if the downstream can't keep up.

Warning

This does unbounded buffering and may lead to OutOfMemoryError.

DROPback to summary
public static final FluxSink.OverflowStrategy DROP

Drop the incoming signal if the downstream is not ready to receive it.

ERRORback to summary
public static final FluxSink.OverflowStrategy ERROR

Signal an IllegalStateException when the downstream can't keep up

IGNOREback to summary
public static final FluxSink.OverflowStrategy IGNORE

Completely ignore downstream backpressure requests.

This may yield IllegalStateException when queues get full downstream.

LATESTback to summary
public static final FluxSink.OverflowStrategy LATEST

Downstream will get only the latest signals from upstream.

Constructor Detail

OverflowStrategyback to summary
private OverflowStrategy()

Method Detail

valueOfback to summary
public static FluxSink.OverflowStrategy valueOf(String name)
valuesback to summary
public static FluxSink.OverflowStrategy[] values()