P
- the type of payload for in and outbound messagespublic class ReactorNettyTcpClient<P> extends Object implements TcpOperations<P>
TcpOperations
.Constructor and Description |
---|
ReactorNettyTcpClient(Function<reactor.netty.tcp.TcpClient,reactor.netty.tcp.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(String host,
int port,
ReactorNettyCodec<P> codec)
Simple constructor with the host and port to use to connect to.
|
ReactorNettyTcpClient(reactor.netty.tcp.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<Void> |
connect(TcpConnectionHandler<P> handler)
Open a new connection.
|
ListenableFuture<Void> |
connect(TcpConnectionHandler<P> handler,
ReconnectStrategy strategy)
Open a new connection and a strategy for reconnecting if the connection fails.
|
protected reactor.netty.tcp.TcpClient |
extendTcpClient(reactor.netty.tcp.TcpClient tcpClient,
TcpConnectionHandler<P> handler)
Provides an opportunity to initialize the
TcpClient for the given
TcpConnectionHandler which may implement sub-interfaces such as
StompTcpConnectionHandler
that expose further information. |
Log |
getLogger()
Return the currently configured Logger.
|
void |
setLogger(Log logger)
Set an alternative logger to use than the one based on the class name.
|
ListenableFuture<Void> |
shutdown()
Shut down and close any open connections.
|
String |
toString() |
public ReactorNettyTcpClient(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(Function<reactor.netty.tcp.TcpClient,reactor.netty.tcp.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(reactor.netty.tcp.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<Void> connect(TcpConnectionHandler<P> handler)
TcpOperations
connect
in interface TcpOperations<P>
handler
- a handler to manage the connectionprotected reactor.netty.tcp.TcpClient extendTcpClient(reactor.netty.tcp.TcpClient tcpClient, TcpConnectionHandler<P> handler)
TcpClient
for the given
TcpConnectionHandler
which may implement sub-interfaces such as
StompTcpConnectionHandler
that expose further information.tcpClient
- the candidate TcpClienthandler
- the handler for the TCP connectionpublic ListenableFuture<Void> connect(TcpConnectionHandler<P> handler, ReconnectStrategy strategy)
TcpOperations
connect
in interface TcpOperations<P>
handler
- a handler to manage the connectionstrategy
- a strategy for reconnectingpublic ListenableFuture<Void> shutdown()
TcpOperations
shutdown
in interface TcpOperations<P>