Class AbstractListenerWriteFlushProcessor<T>
java.lang.Object
org.springframework.http.server.reactive.AbstractListenerWriteFlushProcessor<T>
- Type Parameters:
T
- the type of element signaled to theSubscriber
- All Implemented Interfaces:
Processor<Publisher<? extends T>,
,Void> Publisher<Void>
,Subscriber<Publisher<? extends T>>
public abstract class AbstractListenerWriteFlushProcessor<T>
extends Object
implements Processor<Publisher<? extends T>,Void>
An alternative to
AbstractListenerWriteProcessor
but instead writing
a Publisher<Publisher<T>>
with flush boundaries enforces after
the completion of each nested Publisher.- Since:
- 5.0
- Author:
- Arjen Poutsma, Violeta Georgieva, Rossen Stoyanchev
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final Log
Special logger for debugging Reactive Streams signals. -
Constructor Summary
ConstructorDescriptionAbstractListenerWriteFlushProcessor
(String logPrefix) Create an instance with the given log prefix. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cancel()
Cancel the upstream chain of "write" Publishers only, for example due to Servlet container error/completion notifications.Create a new processor for the current flush boundary.protected abstract void
flush()
Flush the output if ready, or otherwiseisFlushPending()
should return true after.protected void
Invoked when an error happens while flushing.Create an instance with the given log prefix.protected abstract boolean
Whether flushing is pending.protected abstract boolean
Whether writing/flushing is possible.final void
Completion signal from the upstream, write Publisher.final void
Error signal from the upstream, write Publisher.protected final void
Invoked when flushing is possible, either in the same thread after a check viaisWritePossible()
, or as a callback from the underlying container.final void
final void
onSubscribe
(Subscription subscription) final void
subscribe
(Subscriber<? super Void> subscriber)
-
Field Details
-
rsWriteFlushLogger
Special logger for debugging Reactive Streams signals.- See Also:
-
LogDelegateFactory.getHiddenLog(Class)
AbstractListenerReadPublisher.rsReadLogger
AbstractListenerWriteProcessor.rsWriteLogger
WriteResultPublisher.rsWriteResultLogger
-
-
Constructor Details
-
AbstractListenerWriteFlushProcessor
public AbstractListenerWriteFlushProcessor() -
AbstractListenerWriteFlushProcessor
Create an instance with the given log prefix.- Since:
- 5.1
-
-
Method Details
-
getLogPrefix
Create an instance with the given log prefix.- Since:
- 5.1
-
onSubscribe
- Specified by:
onSubscribe
in interfaceSubscriber<T>
-
onNext
- Specified by:
onNext
in interfaceSubscriber<T>
-
onError
Error signal from the upstream, write Publisher. This is also used by subclasses to delegate error notifications from the container.- Specified by:
onError
in interfaceSubscriber<T>
-
onComplete
public final void onComplete()Completion signal from the upstream, write Publisher. This is also used by subclasses to delegate completion notifications from the container.- Specified by:
onComplete
in interfaceSubscriber<T>
-
onFlushPossible
protected final void onFlushPossible()Invoked when flushing is possible, either in the same thread after a check viaisWritePossible()
, or as a callback from the underlying container. -
cancel
protected void cancel()Cancel the upstream chain of "write" Publishers only, for example due to Servlet container error/completion notifications. This should usually be followed up with a call to eitheronError(Throwable)
oronComplete()
to notify the downstream chain, that is unless cancellation came from downstream. -
subscribe
-
createWriteProcessor
Create a new processor for the current flush boundary. -
isWritePossible
protected abstract boolean isWritePossible()Whether writing/flushing is possible. -
flush
Flush the output if ready, or otherwiseisFlushPending()
should return true after.This is primarily for the Servlet non-blocking I/O API where flush cannot be called without a readyToWrite check.
- Throws:
IOException
-
isFlushPending
protected abstract boolean isFlushPending()Whether flushing is pending.This is primarily for the Servlet non-blocking I/O API where flush cannot be called without a readyToWrite check.
-
flushingFailed
Invoked when an error happens while flushing.The default implementation cancels the upstream write publisher and sends an onError downstream as the result of request handling.
-