public abstract class UdpClient extends ClientTransport<UdpClient,UdpClientConfig>
connect()
is ultimately called.
Example:
UdpClient.create()
.doOnConnect(startMetrics)
.doOnConnected(startedMetrics)
.doOnDisconnected(stopMetrics)
.host("127.0.0.1")
.port(1234)
.connect()
.block()
Constructor and Description |
---|
UdpClient() |
Modifier and Type | Method and Description |
---|---|
<A> UdpClient |
attr(io.netty.util.AttributeKey<A> key,
A value)
Update the given attribute key or remove it if the value is null.
|
UdpClient |
bindAddress(java.util.function.Supplier<? extends java.net.SocketAddress> bindAddressSupplier)
Set a new local address to which this transport should bind on subscribe.
|
reactor.core.publisher.Mono<? extends Connection> |
connect()
|
Connection |
connectNow()
Block the
ClientTransport and return a Connection . |
Connection |
connectNow(java.time.Duration timeout)
Block the
ClientTransport and return a Connection . |
static UdpClient |
create()
Prepare a
UdpClient |
UdpClient |
doOnConnect(java.util.function.Consumer<? super UdpClientConfig> doOnConnect)
Set or add a callback called when
ClientTransport is about to connect to the remote endpoint. |
UdpClient |
doOnConnected(java.util.function.Consumer<? super Connection> doOnConnected)
Set or add a callback called after
Connection has been connected. |
UdpClient |
doOnDisconnected(java.util.function.Consumer<? super Connection> doOnDisconnected)
Set or add a callback called after
Connection has been disconnected. |
UdpClient |
handle(java.util.function.BiFunction<? super UdpInbound,? super UdpOutbound,? extends org.reactivestreams.Publisher<java.lang.Void>> handler)
Attach an IO handler to react on connected client
|
UdpClient |
host(java.lang.String host)
The host to which this client should connect.
|
UdpClient |
metrics(boolean enable)
Whether to enable metrics to be collected and registered in Micrometer's
globalRegistry . |
UdpClient |
metrics(boolean enable,
java.util.function.Supplier<? extends ChannelMetricsRecorder> recorder)
Specifies whether the metrics are enabled on the
Transport . |
UdpClient |
observe(ConnectionObserver observer)
Set or add the given
ConnectionObserver to observe the connection state changes. |
<O> UdpClient |
option(io.netty.channel.ChannelOption<O> key,
O value)
Update the given option key or remove it if the value is null.
|
UdpClient |
port(int port)
The port to which this client should connect.
|
UdpClient |
remoteAddress(java.util.function.Supplier<? extends java.net.SocketAddress> remoteAddressSupplier)
The address to which this client should connect on each subscribe.
|
UdpClient |
runOn(io.netty.channel.EventLoopGroup eventLoopGroup)
Run IO loops on the given
EventLoopGroup . |
UdpClient |
runOn(LoopResources channelResources)
Run IO loops on a supplied
EventLoopGroup from the LoopResources container. |
UdpClient |
runOn(LoopResources loopResources,
boolean preferNative)
Run IO loops on a supplied
EventLoopGroup from the LoopResources container. |
UdpClient |
runOn(LoopResources loopResources,
io.netty.channel.socket.InternetProtocolFamily family)
Run IO loops on a supplied
EventLoopGroup from the LoopResources container. |
UdpClient |
wiretap(boolean enable)
Apply or remove a wire logger configuration using
Transport category (logger),
DEBUG logger level and AdvancedByteBufFormat.HEX_DUMP for ByteBuf format,
which means both events and content will be logged and the content will be in hex format. |
UdpClient |
wiretap(java.lang.String category)
Apply a wire logger configuration using the specified category (logger),
DEBUG logger level and AdvancedByteBufFormat.HEX_DUMP for ByteBuf format,
which means both events and content will be logged and the content will be in hex format. |
UdpClient |
wiretap(java.lang.String category,
io.netty.handler.logging.LogLevel level)
Apply a wire logger configuration using the specified category (logger),
logger level and
AdvancedByteBufFormat.HEX_DUMP for ByteBuf format,
which means both events and content will be logged and the content will be in hex format. |
doAfterResolve, doOnResolve, doOnResolveError, noProxy, proxy, resolver, resolver, warmup
channelGroup, configuration, doOnChannelInit, duplicate, wiretap, wiretap
public final <A> UdpClient attr(io.netty.util.AttributeKey<A> key, @Nullable A value)
Transport
attr
in class Transport<UdpClient,UdpClientConfig>
A
- the attribute typekey
- the AttributeKey
keyvalue
- the AttributeKey
valueTransport
referencepublic final UdpClient bindAddress(java.util.function.Supplier<? extends java.net.SocketAddress> bindAddressSupplier)
Transport
bindAddress
in class Transport<UdpClient,UdpClientConfig>
bindAddressSupplier
- A supplier of the address to bind to.Transport
public final reactor.core.publisher.Mono<? extends Connection> connect()
ClientTransport
ClientTransport
and return a Mono
of Connection
. If
Mono
is cancelled, the underlying connection will be aborted. Once the
Connection
has been emitted and is not necessary anymore, disposing must be
done by the user via DisposableChannel.dispose()
.connect
in class ClientTransport<UdpClient,UdpClientConfig>
Mono
of Connection
public final Connection connectNow()
ClientTransport
ClientTransport
and return a Connection
. Disposing must be
done by the user via DisposableChannel.dispose()
. The max connection
timeout is 45 seconds.connectNow
in class ClientTransport<UdpClient,UdpClientConfig>
Connection
public final Connection connectNow(java.time.Duration timeout)
ClientTransport
ClientTransport
and return a Connection
. Disposing must be
done by the user via DisposableChannel.dispose()
.connectNow
in class ClientTransport<UdpClient,UdpClientConfig>
timeout
- connect timeout (resolution: ns)Connection
public final UdpClient doOnConnect(java.util.function.Consumer<? super UdpClientConfig> doOnConnect)
ClientTransport
ClientTransport
is about to connect to the remote endpoint.doOnConnect
in class ClientTransport<UdpClient,UdpClientConfig>
doOnConnect
- a consumer observing connect eventsClientTransport
referencepublic final UdpClient doOnConnected(java.util.function.Consumer<? super Connection> doOnConnected)
ClientTransport
Connection
has been connected.doOnConnected
in class ClientTransport<UdpClient,UdpClientConfig>
doOnConnected
- a consumer observing connected eventsClientTransport
referencepublic final UdpClient doOnDisconnected(java.util.function.Consumer<? super Connection> doOnDisconnected)
ClientTransport
Connection
has been disconnected.doOnDisconnected
in class ClientTransport<UdpClient,UdpClientConfig>
doOnDisconnected
- a consumer observing disconnected eventsClientTransport
referencepublic final UdpClient handle(java.util.function.BiFunction<? super UdpInbound,? super UdpOutbound,? extends org.reactivestreams.Publisher<java.lang.Void>> handler)
handler
- an IO handler that can dispose underlying connection when Publisher
terminates.UdpClient
referencepublic final UdpClient host(java.lang.String host)
ClientTransport
host
in class ClientTransport<UdpClient,UdpClientConfig>
host
- the host to connect toClientTransport
referencepublic final UdpClient metrics(boolean enable)
Transport
globalRegistry
.
Applications can separately register their own
filters
.
For example, to put an upper bound on the number of tags produced:
MeterFilter filter = ... ; Metrics.globalRegistry.config().meterFilter(MeterFilter.maximumAllowableTags(prefix, 100, filter));
By default this is not enabled.
metrics
in class Transport<UdpClient,UdpClientConfig>
enable
- true enables metrics collection; false disables itTransport
referencepublic final UdpClient metrics(boolean enable, java.util.function.Supplier<? extends ChannelMetricsRecorder> recorder)
Transport
Transport
.
All generated metrics are provided to the specified recorder
which is only instantiated if metrics are being enabled.metrics
in class Transport<UdpClient,UdpClientConfig>
enable
- if true enables the metrics on the Transport
.recorder
- a supplier for the ChannelMetricsRecorder
Transport
referencepublic final UdpClient observe(ConnectionObserver observer)
Transport
ConnectionObserver
to observe the connection state changes.observe
in class Transport<UdpClient,UdpClientConfig>
observer
- the ConnectionObserver
to be set or addTransport
referencepublic final <O> UdpClient option(io.netty.channel.ChannelOption<O> key, @Nullable O value)
Transport
ChannelOption.AUTO_READ
option will be ignored. It is configured to be false
.option
in class Transport<UdpClient,UdpClientConfig>
O
- the option typekey
- the ChannelOption
keyvalue
- the ChannelOption
value or nullTransport
referencepublic final UdpClient port(int port)
ClientTransport
port
in class ClientTransport<UdpClient,UdpClientConfig>
port
- the port to connect toClientTransport
referencepublic final UdpClient remoteAddress(java.util.function.Supplier<? extends java.net.SocketAddress> remoteAddressSupplier)
ClientTransport
remoteAddress
in class ClientTransport<UdpClient,UdpClientConfig>
remoteAddressSupplier
- A supplier of the address to connect to.ClientTransport
public final UdpClient runOn(io.netty.channel.EventLoopGroup eventLoopGroup)
Transport
EventLoopGroup
.runOn
in class Transport<UdpClient,UdpClientConfig>
eventLoopGroup
- an eventLoopGroup to shareTransport
referencepublic final UdpClient runOn(LoopResources channelResources)
Transport
EventLoopGroup
from the LoopResources
container.
Will prefer native (epoll/kqueue) implementation if available
unless the environment property reactor.netty.native
is set to false
.runOn
in class Transport<UdpClient,UdpClientConfig>
channelResources
- a LoopResources
accepting native runtime expectation and
returning an eventLoopGroupTransport
referencepublic final UdpClient runOn(LoopResources loopResources, boolean preferNative)
EventLoopGroup
from the LoopResources
container.runOn
in class ClientTransport<UdpClient,UdpClientConfig>
loopResources
- a new loop resourcespreferNative
- should prefer running on epoll, kqueue or similar instead of java NIOUdpServer
referencepublic final UdpClient runOn(LoopResources loopResources, io.netty.channel.socket.InternetProtocolFamily family)
EventLoopGroup
from the LoopResources
container.loopResources
- a new loop resourcesfamily
- a specific InternetProtocolFamily
to run withUdpClient
referencepublic final UdpClient wiretap(boolean enable)
Transport
Transport
category (logger),
DEBUG
logger level and AdvancedByteBufFormat.HEX_DUMP
for ByteBuf
format,
which means both events and content will be logged and the content will be in hex format.wiretap
in class Transport<UdpClient,UdpClientConfig>
enable
- specifies whether the wire logger configuration will be added to the pipelineTransport
referencepublic final UdpClient wiretap(java.lang.String category)
Transport
DEBUG
logger level and AdvancedByteBufFormat.HEX_DUMP
for ByteBuf
format,
which means both events and content will be logged and the content will be in hex format.wiretap
in class Transport<UdpClient,UdpClientConfig>
category
- the logger categoryTransport
referencepublic final UdpClient wiretap(java.lang.String category, io.netty.handler.logging.LogLevel level)
Transport
AdvancedByteBufFormat.HEX_DUMP
for ByteBuf
format,
which means both events and content will be logged and the content will be in hex format.wiretap
in class Transport<UdpClient,UdpClientConfig>
category
- the logger categorylevel
- the logger levelTransport
reference