Top Description Inners Fields Constructors Methods
reactor.netty.udp

public abstract Class UdpClient

extends ClientTransport<UdpClient, UdpClientConfig>
Class Inheritance
Known Direct Subclasses
reactor.netty.udp.UdpClientConnect
Imports
java.net.SocketAddress, java.time.Duration, java.util.Objects, java.util.function.BiFunction, .Consumer, .Supplier, io.netty.channel.ChannelOption, .EventLoopGroup, io.netty.channel.socket.InternetProtocolFamily, io.netty.handler.logging.LogLevel, io.netty.util.AttributeKey, org.reactivestreams.Publisher, reactor.core.publisher.Mono, reactor.netty.Connection, .ConnectionObserver, reactor.netty.channel.ChannelMetricsRecorder, reactor.netty.resources.LoopResources, reactor.netty.transport.ClientTransport, reactor.util.Logger, .Loggers, reactor.util.annotation.Nullable

A UdpClient allows building in a safe immutable way a UDP client that is materialized and connecting when connect() is ultimately called.

Example:

UdpClient.create()
         .doOnConnect(startMetrics)
         .doOnConnected(startedMetrics)
         .doOnDisconnected(stopMetrics)
         .host("127.0.0.1")
         .port(1234)
         .connect()
         .block()

Authors
Stephane Maldini, Violeta Georgieva

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final <A> UdpClient
attr(AttributeKey<A>
the AttributeKey key
key
,
A
the AttributeKey value
value
)

Overrides reactor.netty.transport.Transport.attr.

Update the given attribute key or remove it if the value is null.
public final UdpClient
bindAddress(Supplier<? extends SocketAddress>
A supplier of the address to bind to.
bindAddressSupplier
)

Overrides reactor.netty.transport.Transport.bindAddress.

Set a new local address to which this transport should bind on subscribe.
public final Mono<? extends Connection>
public final Connection
public final Connection
connectNow(Duration
connect timeout (resolution: ns)
timeout
)

Overrides reactor.netty.transport.ClientTransport.connectNow.

Block the ClientTransport and return a Connection.
public static UdpClient

Returns:

a UdpClient
create
()

Prepare a UdpClient.

public final UdpClient
doOnConnect(Consumer<? super UdpClientConfig>
a consumer observing connect events
doOnConnect
)

Overrides reactor.netty.transport.ClientTransport.doOnConnect.

Set or add a callback called when ClientTransport is about to connect to the remote endpoint.
public final UdpClient
doOnConnected(Consumer<? super Connection>
a consumer observing connected events
doOnConnected
)

Overrides reactor.netty.transport.ClientTransport.doOnConnected.

Set or add a callback called after Connection has been connected.
public final UdpClient
doOnDisconnected(Consumer<? super Connection>
a consumer observing disconnected events
doOnDisconnected
)

Overrides reactor.netty.transport.ClientTransport.doOnDisconnected.

Set or add a callback called after Connection has been disconnected.
public final UdpClient

Returns:

a new UdpClient reference
handle
(BiFunction<? super UdpInbound, ? super UdpOutbound, ? extends Publisher<Void>>
an IO handler that can dispose underlying connection when Publisher terminates.
handler
)

Attach an IO handler to react on connected client.

public final UdpClient
host(String
the host to connect to
host
)

Overrides reactor.netty.transport.ClientTransport.host.

The host to which this client should connect.
public final UdpClient
metrics(boolean
true enables metrics collection; false disables it
enable
)

Overrides reactor.netty.transport.Transport.metrics.

Whether to enable metrics to be collected and registered in Micrometer's globalRegistry.
public final UdpClient
metrics(boolean
if true enables the metrics on the Transport.
enable
,
Supplier<? extends ChannelMetricsRecorder>
a supplier for the ChannelMetricsRecorder
recorder
)

Overrides reactor.netty.transport.Transport.metrics.

Specifies whether the metrics are enabled on the Transport.
public final UdpClient
observe(ConnectionObserver
the ConnectionObserver to be set or add
observer
)

Overrides reactor.netty.transport.Transport.observe.

Set or add the given ConnectionObserver to observe the connection state changes.
public final <O> UdpClient
option(ChannelOption<O> key, O
the ChannelOption value or null
value
)

Overrides reactor.netty.transport.Transport.option.

Update the given option key or remove it if the value is null.
public final UdpClient
port(int
the port to connect to
port
)

Overrides reactor.netty.transport.ClientTransport.port.

The port to which this client should connect.
public final UdpClient
remoteAddress(Supplier<? extends SocketAddress>
A supplier of the address to connect to.
remoteAddressSupplier
)

Overrides reactor.netty.transport.ClientTransport.remoteAddress.

The address to which this client should connect on each subscribe.
public final UdpClient
runOn(EventLoopGroup
an eventLoopGroup to share
eventLoopGroup
)

Overrides reactor.netty.transport.Transport.runOn.

Run IO loops on the given EventLoopGroup.
public final UdpClient
runOn(LoopResources
a LoopResources accepting native runtime expectation and returning an eventLoopGroup
channelResources
)

Overrides reactor.netty.transport.Transport.runOn.

Run IO loops on a supplied EventLoopGroup from the LoopResources container.
public final UdpClient

Returns:

a new UdpServer reference
runOn
(LoopResources
a new loop resources
loopResources
,
boolean
should prefer running on epoll, kqueue or similar instead of java NIO
preferNative
)

Overrides reactor.netty.transport.ClientTransport.runOn.

Run IO loops on a supplied EventLoopGroup from the LoopResources container.
public final UdpClient

Returns:

a new UdpClient reference
runOn
(LoopResources
a new loop resources
loopResources
,
InternetProtocolFamily
a specific InternetProtocolFamily to run with
family
)

Run IO loops on a supplied EventLoopGroup from the LoopResources container.

public final UdpClient
wiretap(boolean
specifies whether the wire logger configuration will be added to the pipeline
enable
)

Overrides reactor.netty.transport.Transport.wiretap.

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.
public final UdpClient
wiretap(String
the logger category
category
)

Overrides reactor.netty.transport.Transport.wiretap.

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.
public final UdpClient
wiretap(String
the logger category
category
,
LogLevel
the logger level
level
)

Overrides reactor.netty.transport.Transport.wiretap.

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.
Inherited from reactor.netty.transport.ClientTransport:
doAfterResolvedoOnResolvedoOnResolveErrornoProxyproxyproxyWithSystemPropertiesresolverresolverwarmup

Field Detail

logback to summary
pack-priv static final Logger log

Hides reactor.netty.transport.Transport.log.

Constructor Detail

UdpClientback to summary
public UdpClient()

Method Detail

attrback to summary
public final <A> UdpClient attr(AttributeKey<A> key, A value)

Overrides reactor.netty.transport.Transport.attr.

Doc from reactor.netty.transport.Transport.attr.

Update the given attribute key or remove it if the value is null.

Parameters
<A>
the attribute type
key:AttributeKey<A>

the AttributeKey key

value:A

the AttributeKey value

Returns:UdpClient

a new Transport reference

Annotations
@Override
bindAddressback to summary
public final UdpClient bindAddress(Supplier<? extends SocketAddress> bindAddressSupplier)

Overrides reactor.netty.transport.Transport.bindAddress.

Doc from reactor.netty.transport.Transport.bindAddress.

Set a new local address to which this transport should bind on subscribe.

Parameters
bindAddressSupplier:Supplier<? extends SocketAddress>

A supplier of the address to bind to.

Returns:UdpClient

a new Transport

Annotations
@Override
connectback to summary
public final Mono<? extends Connection> connect()

Overrides reactor.netty.transport.ClientTransport.connect.

Doc from reactor.netty.transport.ClientTransport.connect.

Connect the 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 Connection#dispose().

Returns:Mono<? extends Connection>

a Mono of Connection

Annotations
@Override
connectNowback to summary
public final Connection connectNow()

Overrides reactor.netty.transport.ClientTransport.connectNow.

Doc from reactor.netty.transport.ClientTransport.connectNow.

Block the ClientTransport and return a Connection. Disposing must be done by the user via Connection#dispose(). The max connection timeout is 45 seconds.

Returns:Connection

a Connection

Annotations
@Override
connectNowback to summary
public final Connection connectNow(Duration timeout)

Overrides reactor.netty.transport.ClientTransport.connectNow.

Doc from reactor.netty.transport.ClientTransport.connectNow.

Block the ClientTransport and return a Connection. Disposing must be done by the user via Connection#dispose().

Parameters
timeout:Duration

connect timeout (resolution: ns)

Returns:Connection

a Connection

Annotations
@Override
createback to summary
public static UdpClient create()

Prepare a UdpClient.

Returns:UdpClient

a UdpClient

doOnConnectback to summary
public final UdpClient doOnConnect(Consumer<? super UdpClientConfig> doOnConnect)

Overrides reactor.netty.transport.ClientTransport.doOnConnect.

Doc from reactor.netty.transport.ClientTransport.doOnConnect.

Set or add a callback called when ClientTransport is about to connect to the remote endpoint.

Parameters
doOnConnect:Consumer<? super UdpClientConfig>

a consumer observing connect events

Returns:UdpClient

a new ClientTransport reference

Annotations
@Override
doOnConnectedback to summary
public final UdpClient doOnConnected(Consumer<? super Connection> doOnConnected)

Overrides reactor.netty.transport.ClientTransport.doOnConnected.

Doc from reactor.netty.transport.ClientTransport.doOnConnected.

Set or add a callback called after Connection has been connected.

Parameters
doOnConnected:Consumer<? super Connection>

a consumer observing connected events

Returns:UdpClient

a new ClientTransport reference

Annotations
@Override
doOnDisconnectedback to summary
public final UdpClient doOnDisconnected(Consumer<? super Connection> doOnDisconnected)

Overrides reactor.netty.transport.ClientTransport.doOnDisconnected.

Doc from reactor.netty.transport.ClientTransport.doOnDisconnected.

Set or add a callback called after Connection has been disconnected.

Parameters
doOnDisconnected:Consumer<? super Connection>

a consumer observing disconnected events

Returns:UdpClient

a new ClientTransport reference

Annotations
@Override
handleback to summary
public final UdpClient handle(BiFunction<? super UdpInbound, ? super UdpOutbound, ? extends Publisher<Void>> handler)

Attach an IO handler to react on connected client.

Parameters
handler:BiFunction<? super UdpInbound, ? super UdpOutbound, ? extends Publisher<Void>>

an IO handler that can dispose underlying connection when Publisher terminates.

Returns:UdpClient

a new UdpClient reference

hostback to summary
public final UdpClient host(String host)

Overrides reactor.netty.transport.ClientTransport.host.

Doc from reactor.netty.transport.ClientTransport.host.

The host to which this client should connect.

Parameters
host:String

the host to connect to

Returns:UdpClient

a new ClientTransport reference

Annotations
@Override
metricsback to summary
public final UdpClient metrics(boolean enable)

Overrides reactor.netty.transport.Transport.metrics.

Doc from reactor.netty.transport.Transport.metrics.

Whether to enable metrics to be collected and registered in Micrometer's 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.

Parameters
enable:boolean

true enables metrics collection; false disables it

Returns:UdpClient

a new Transport reference

Annotations
@Override
metricsback to summary
public final UdpClient metrics(boolean enable, Supplier<? extends ChannelMetricsRecorder> recorder)

Overrides reactor.netty.transport.Transport.metrics.

Doc from reactor.netty.transport.Transport.metrics.

Specifies whether the metrics are enabled on the Transport. All generated metrics are provided to the specified recorder which is only instantiated if metrics are being enabled (the instantiation is not lazy, but happens immediately, while configuring the Transport).

Parameters
enable:boolean

if true enables the metrics on the Transport.

recorder:Supplier<? extends ChannelMetricsRecorder>

a supplier for the ChannelMetricsRecorder

Returns:UdpClient

a new Transport reference

Annotations
@Override
observeback to summary
public final UdpClient observe(ConnectionObserver observer)

Overrides reactor.netty.transport.Transport.observe.

Doc from reactor.netty.transport.Transport.observe.

Set or add the given ConnectionObserver to observe the connection state changes.

Parameters
observer:ConnectionObserver

the ConnectionObserver to be set or add

Returns:UdpClient

a new Transport reference

Annotations
@Override
optionback to summary
public final <O> UdpClient option(ChannelOption<O> key, O value)

Overrides reactor.netty.transport.Transport.option.

Doc from reactor.netty.transport.Transport.option.

Update the given option key or remove it if the value is null.

Note

Setting ChannelOption#AUTO_READ option will be ignored. It is configured to be false.

Parameters
<O>
the option type
key:ChannelOption<O>

the ChannelOption key

value:O

the ChannelOption value or null

Returns:UdpClient

a new Transport reference

Annotations
@Override
portback to summary
public final UdpClient port(int port)

Overrides reactor.netty.transport.ClientTransport.port.

Doc from reactor.netty.transport.ClientTransport.port.

The port to which this client should connect.

Parameters
port:int

the port to connect to

Returns:UdpClient

a new ClientTransport reference

Annotations
@Override
remoteAddressback to summary
public final UdpClient remoteAddress(Supplier<? extends SocketAddress> remoteAddressSupplier)

Overrides reactor.netty.transport.ClientTransport.remoteAddress.

Doc from reactor.netty.transport.ClientTransport.remoteAddress.

The address to which this client should connect on each subscribe.

Parameters
remoteAddressSupplier:Supplier<? extends SocketAddress>

A supplier of the address to connect to.

Returns:UdpClient

a new ClientTransport

Annotations
@Override
runOnback to summary
public final UdpClient runOn(EventLoopGroup eventLoopGroup)

Overrides reactor.netty.transport.Transport.runOn.

Doc from reactor.netty.transport.Transport.runOn.

Run IO loops on the given EventLoopGroup.

Parameters
eventLoopGroup:EventLoopGroup

an eventLoopGroup to share

Returns:UdpClient

a new Transport reference

Annotations
@Override
runOnback to summary
public final UdpClient runOn(LoopResources channelResources)

Overrides reactor.netty.transport.Transport.runOn.

Doc from reactor.netty.transport.Transport.runOn.

Run IO loops on a supplied EventLoopGroup from the LoopResources container. Will prefer native (epoll/kqueue) implementation if available unless the environment property reactor.netty.native is set to false.

Parameters
channelResources:LoopResources

a LoopResources accepting native runtime expectation and returning an eventLoopGroup

Returns:UdpClient

a new Transport reference

Annotations
@Override
runOnback to summary
public final UdpClient runOn(LoopResources loopResources, boolean preferNative)

Overrides reactor.netty.transport.ClientTransport.runOn.

Run IO loops on a supplied EventLoopGroup from the LoopResources container.

Parameters
loopResources:LoopResources

a new loop resources

preferNative:boolean

should prefer running on epoll, kqueue or similar instead of java NIO

Returns:UdpClient

a new UdpServer reference

Annotations
@Override
runOnback to summary
public final UdpClient runOn(LoopResources loopResources, InternetProtocolFamily family)

Run IO loops on a supplied EventLoopGroup from the LoopResources container.

Parameters
loopResources:LoopResources

a new loop resources

family:InternetProtocolFamily

a specific InternetProtocolFamily to run with

Returns:UdpClient

a new UdpClient reference

wiretapback to summary
public final UdpClient wiretap(boolean enable)

Overrides reactor.netty.transport.Transport.wiretap.

Doc from reactor.netty.transport.Transport.wiretap.

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.

Parameters
enable:boolean

specifies whether the wire logger configuration will be added to the pipeline

Returns:UdpClient

a new Transport reference

Annotations
@Override
wiretapback to summary
public final UdpClient wiretap(String category)

Overrides reactor.netty.transport.Transport.wiretap.

Doc from reactor.netty.transport.Transport.wiretap.

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.

Parameters
category:String

the logger category

Returns:UdpClient

a new Transport reference

Annotations
@Override
wiretapback to summary
public final UdpClient wiretap(String category, LogLevel level)

Overrides reactor.netty.transport.Transport.wiretap.

Doc from reactor.netty.transport.Transport.wiretap.

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.

Parameters
category:String

the logger category

level:LogLevel

the logger level

Returns:UdpClient

a new Transport reference

Annotations
@Override
reactor.netty.udp back to summary

pack-priv final Class UdpClient.OnConnectedHandle

extends Object
implements Consumer<Connection>
Class Inheritance
All Implemented Interfaces
java.util.function.Consumer

Field Summary

Modifier and TypeField and Description
pack-priv final BiFunction<? super UdpInbound, ? super UdpOutbound, ? extends Publisher<Void>>

Constructor Summary

AccessConstructor and Description
pack-priv
OnConnectedHandle(BiFunction<? super UdpInbound, ? super UdpOutbound, ? extends Publisher<Void>> handler)

Method Summary

Modifier and TypeMethod and Description
public void
accept(Connection
the input argument
c
)

Implements java.util.function.Consumer.accept.

Performs this operation on the given argument.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlerback to summary
pack-priv final BiFunction<? super UdpInbound, ? super UdpOutbound, ? extends Publisher<Void>> handler

Constructor Detail

OnConnectedHandleback to summary
pack-priv OnConnectedHandle(BiFunction<? super UdpInbound, ? super UdpOutbound, ? extends Publisher<Void>> handler)

Method Detail

acceptback to summary
public void accept(Connection c)

Implements java.util.function.Consumer.accept.

Doc from java.util.function.Consumer.accept.

Performs this operation on the given argument.

Parameters
c:Connection

the input argument

Annotations
@Override