P
- the type of payload for in and outbound messagespublic class ReactorNettyTcpClient<P> extends java.lang.Object implements TcpOperations<P>
TcpOperations
.Modifier and Type | Class and Description |
---|---|
private class |
ReactorNettyTcpClient.ReactorNettyHandler |
private static class |
ReactorNettyTcpClient.StompMessageDecoder<P> |
Modifier and Type | Field and Description |
---|---|
private ChannelGroup |
channelGroup |
private ReactorNettyCodec<P> |
codec |
private Log |
logger |
private LoopResources |
loopResources |
private ConnectionProvider |
poolResources |
private static int |
PUBLISH_ON_BUFFER_SIZE |
private Scheduler |
scheduler |
private boolean |
stopping |
private TcpClient |
tcpClient |
Constructor and Description |
---|
ReactorNettyTcpClient(java.util.function.Function<TcpClient,TcpClient> clientConfigurer,
ReactorNettyCodec<P> codec)
A variant of
ReactorNettyTcpClient(String, int, ReactorNettyCodec)
that still manages the lifecycle of the TcpClient and underlying
resources, but allows for direct configuration of other properties of the
client through a Function<TcpClient, TcpClient> . |
ReactorNettyTcpClient(java.lang.String host,
int port,
ReactorNettyCodec<P> codec)
Simple constructor with the host and port to use to connect to.
|
ReactorNettyTcpClient(TcpClient tcpClient,
ReactorNettyCodec<P> codec)
Constructor with an externally created
TcpClient instance whose
lifecycle is expected to be managed externally. |
Modifier and Type | Method and Description |
---|---|
ListenableFuture<java.lang.Void> |
connect(TcpConnectionHandler<P> handler)
Open a new connection.
|
ListenableFuture<java.lang.Void> |
connect(TcpConnectionHandler<P> handler,
ReconnectStrategy strategy)
Open a new connection and a strategy for reconnecting if the connection fails.
|
Log |
getLogger()
Return the currently configured Logger.
|
private ListenableFuture<java.lang.Void> |
handleShuttingDownConnectFailure(TcpConnectionHandler<P> handler) |
private <T> java.util.function.Function<<any>,<any>> |
reconnectFunction(ReconnectStrategy reconnectStrategy) |
void |
setLogger(Log logger)
Set an alternative logger to use than the one based on the class name.
|
ListenableFuture<java.lang.Void> |
shutdown()
Shut down and close any open connections.
|
private <any> |
stopScheduler() |
java.lang.String |
toString() |
private <T> java.util.function.Consumer<T> |
updateConnectMono(<any> connectMono) |
private static final int PUBLISH_ON_BUFFER_SIZE
private final TcpClient tcpClient
private final ReactorNettyCodec<P> codec
@Nullable private final ChannelGroup channelGroup
@Nullable private final LoopResources loopResources
@Nullable private final ConnectionProvider poolResources
private final Scheduler scheduler
private Log logger
private volatile boolean stopping
public ReactorNettyTcpClient(java.lang.String host, int port, ReactorNettyCodec<P> codec)
This constructor manages the lifecycle of the TcpClient
and
underlying resources such as ConnectionProvider
,
LoopResources
, and ChannelGroup
.
For full control over the initialization and lifecycle of the
TcpClient, use ReactorNettyTcpClient(TcpClient, ReactorNettyCodec)
.
host
- the host to connect toport
- the port to connect tocodec
- for encoding and decoding the input/output byte streamsStompReactorNettyCodec
public ReactorNettyTcpClient(java.util.function.Function<TcpClient,TcpClient> clientConfigurer, ReactorNettyCodec<P> codec)
ReactorNettyTcpClient(String, int, ReactorNettyCodec)
that still manages the lifecycle of the TcpClient
and underlying
resources, but allows for direct configuration of other properties of the
client through a Function<TcpClient, TcpClient>
.clientConfigurer
- the configurer functioncodec
- for encoding and decoding the input/output byte streamsStompReactorNettyCodec
public ReactorNettyTcpClient(TcpClient tcpClient, ReactorNettyCodec<P> codec)
TcpClient
instance whose
lifecycle is expected to be managed externally.tcpClient
- the TcpClient instance to usecodec
- for encoding and decoding the input/output byte streamsStompReactorNettyCodec
public void setLogger(Log logger)
logger
- the logger to usepublic Log getLogger()
public ListenableFuture<java.lang.Void> connect(TcpConnectionHandler<P> handler)
TcpOperations
connect
in interface TcpOperations<P>
handler
- a handler to manage the connectionpublic ListenableFuture<java.lang.Void> connect(TcpConnectionHandler<P> handler, ReconnectStrategy strategy)
TcpOperations
connect
in interface TcpOperations<P>
handler
- a handler to manage the connectionstrategy
- a strategy for reconnectingprivate ListenableFuture<java.lang.Void> handleShuttingDownConnectFailure(TcpConnectionHandler<P> handler)
private <T> java.util.function.Consumer<T> updateConnectMono(<any> connectMono)
private <T> java.util.function.Function<<any>,<any>> reconnectFunction(ReconnectStrategy reconnectStrategy)
public ListenableFuture<java.lang.Void> shutdown()
TcpOperations
shutdown
in interface TcpOperations<P>
private <any> stopScheduler()
public java.lang.String toString()
toString
in class java.lang.Object