Interface NettyOutbound
- All Known Subinterfaces:
HttpServerResponse
,QuicOutbound
,UdpOutbound
,WebsocketOutbound
- All Known Implementing Classes:
ChannelOperations
,HttpOperations
,HttpOperations.PostHeadersNettyOutbound
Channel
.
Note: With HTTP, chaining multiple send operations is discouraged and will not work as expected
when send involves scalar or mono publishers. For instance send(flux).send(mono)
or send(flux).sendObject(message)
will ignore send(flux)
.
This is an anticipation of an API simplification moving forward next versions where
send will not return NettyOutbound
anymore.
- Author:
- Stephane Maldini
-
Method Summary
Modifier and TypeMethodDescriptionalloc()
Returns the assignedByteBufAllocator
.default NettyOutbound
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).default NettyOutbound
sendByteArray
(Publisher<? extends byte[]> dataStream) Sends bytes to the peer, listens for any error on write and closes on terminal signal (complete|error).default NettyOutbound
Sends content from givenPath
usingFileChannel.transferTo(long, long, WritableByteChannel)
support.default NettyOutbound
Sends content from the givenPath
usingFileChannel.transferTo(long, long, WritableByteChannel)
support, if the system supports it, the path resolves to a local file systemFile
, compression and SSL/TLS is not enabled, then transfer will use zero-byte copy to the peer., otherwise chunked read/write will be used.default NettyOutbound
sendFileChunked
(Path file, long position, long count) Sends content from givenPath
using chunked read/write.default NettyOutbound
sendGroups
(Publisher<? extends Publisher<? extends ByteBuf>> dataStreams) Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).sendObject
(Object message) Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).default NettyOutbound
sendObject
(Publisher<?> dataStream) Sends an object through Netty pipeline.sendObject
(Publisher<?> dataStream, Predicate<Object> predicate) Sends an object through Netty pipeline.default NettyOutbound
sendString
(Publisher<? extends String> dataStream) Sends String to the peer, listens for any error on write and closes on terminal signal (complete|error).default NettyOutbound
sendString
(Publisher<? extends String> dataStream, Charset charset) Sends String to the peer, listens for any error on write and closes on terminal signal (complete|error).<S> NettyOutbound
sendUsing
(Callable<? extends S> sourceInput, BiFunction<? super Connection, ? super S, ?> mappedInput, Consumer<? super S> sourceCleanup) Binds a send to a starting/cleanup lifecycledefault void
subscribe
(Subscriber<? super Void> s) Subscribes aVoid
subscriber to this outbound and trigger all eventual parent outbound send.then()
Obtains aMono
of pending outbound(s) write completion.default NettyOutbound
default NettyOutbound
Append aPublisher
task such as a Mono and return a newNettyOutbound
to sequence further send.withConnection
(Consumer<? super Connection> withConnection) Call the passed callback with aConnection
to operate on the underlyingChannel
state.
-
Method Details
-
alloc
ByteBufAllocator alloc()Returns the assignedByteBufAllocator
.- Returns:
- the
ByteBufAllocator
-
neverComplete
-
send
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).A new
NettyOutbound
type (or the same) for typed send sequences.Note: Nesting any send* method is not supported.
- Parameters:
dataStream
- the dataStream publishing OUT items to write on this channel- Returns:
- A new
NettyOutbound
to append further send. It will emit a complete signal successful sequence write (e.g. after "flush") or any error during write.
-
send
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).A new
NettyOutbound
type (or the same) for typed send sequences.Note: Nesting any send* method is not supported.
- Parameters:
dataStream
- the dataStream publishing OUT items to write on this channelpredicate
- that returns true if explicit flush operation is needed after that buffer- Returns:
- A new
NettyOutbound
to append further send. It will emit a complete signal successful sequence write (e.g. after "flush") or any error during write.
-
sendByteArray
Sends bytes to the peer, listens for any error on write and closes on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.Note: Nesting any send* method is not supported.
- Parameters:
dataStream
- the dataStream publishing Buffer items to write on this channel- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendFile
Sends content from givenPath
usingFileChannel.transferTo(long, long, WritableByteChannel)
support. If the system supports it and the path resolves to a local file systemFile
then transfer will use zero-byte copy to the peer.It will listen for any error on write and close on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.
Note: this will emit
FileRegion
in the outboundChannelPipeline
Note: Nesting any send* method is not supported.- Parameters:
file
- the file Path- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendFile
Sends content from the givenPath
usingFileChannel.transferTo(long, long, WritableByteChannel)
support, if the system supports it, the path resolves to a local file systemFile
, compression and SSL/TLS is not enabled, then transfer will use zero-byte copy to the peer., otherwise chunked read/write will be used.It will listens for any error on write and closes on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.
Note: Nesting any send* method is not supported.
- Parameters:
file
- the file Pathposition
- where to startcount
- how much to transfer- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendFileChunked
Sends content from givenPath
using chunked read/write.It will listen for any error on write and close on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.
Note: Nesting any send* method is not supported.
- Parameters:
file
- the file Pathposition
- where to startcount
- how much to transfer- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendGroups
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error). Each individualPublisher
completion will flush the underlying IO runtime.Note: Nesting any send* method is not supported.
- Parameters:
dataStreams
- the dataStream publishing OUT items to write on this channel- Returns:
- A
Mono
to signal successful sequence write (e.g. after "flush") or any error during write
-
sendObject
Sends an object through Netty pipeline. If type ofPublisher
, sends all signals, flushing on complete by default. Write occur in FIFO sequence.Note: Nesting any send* method is not supported.
- Parameters:
dataStream
- the dataStream publishing items to write on this channel or a simple pojo supported by configured Netty handlers- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendObject
Sends an object through Netty pipeline. If type ofPublisher
, sends all signals, flushing on complete by default. Write occur in FIFO sequence.Note: Nesting any send* method is not supported.
- Parameters:
dataStream
- the dataStream publishing items to write on this channel or a simple pojo supported by configured Netty handlerspredicate
- that returns true if explicit flush operation is needed after that object- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendObject
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).Note: Nesting any send* method is not supported.
- Parameters:
message
- the object to publish- Returns:
- A
Mono
to signal successful sequence write (e.g. after "flush") or any error during write
-
sendString
Sends String to the peer, listens for any error on write and closes on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.Note: Nesting any send* method is not supported.
- Parameters:
dataStream
- the dataStream publishing Buffer items to write on this channel- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendString
Sends String to the peer, listens for any error on write and closes on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.Note: Nesting any send* method is not supported.
- Parameters:
dataStream
- the dataStream publishing Buffer items to write on this channelcharset
- the encoding charset- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendUsing
<S> NettyOutbound sendUsing(Callable<? extends S> sourceInput, BiFunction<? super Connection, ? super S, ?> mappedInput, Consumer<? super S> sourceCleanup) Binds a send to a starting/cleanup lifecycleNote: Nesting any send* method is not supported.
- Type Parameters:
S
- state type- Parameters:
sourceInput
- state generatormappedInput
- input to sendsourceCleanup
- state cleaner- Returns:
- a new
NettyOutbound
-
subscribe
Subscribes aVoid
subscriber to this outbound and trigger all eventual parent outbound send.- Specified by:
subscribe
in interfacePublisher<Void>
- Parameters:
s
- theSubscriber
to listen for send sequence completion/failure
-
then
Obtains aMono
of pending outbound(s) write completion.- Returns:
- a
Mono
of pending outbound(s) write completion
-
then
- Parameters:
other
- thePublisher
to subscribe to when this pending outboundthen()
is complete;- Returns:
- a new
NettyOutbound
-
then
Append aPublisher
task such as a Mono and return a newNettyOutbound
to sequence further send.- Parameters:
other
- thePublisher
to subscribe to when this pending outboundthen()
is complete;onCleanup
- a cleanup hook when other has terminated or cancelled- Returns:
- a new
NettyOutbound
that
-
withConnection
Call the passed callback with aConnection
to operate on the underlyingChannel
state.- Parameters:
withConnection
- connection callback- Returns:
- the
Connection
-