P
- the type of payload for in and outbound messagespublic class ReactorNettyTcpClient<P> extends java.lang.Object implements TcpOperations<P>
TcpOperations
.Constructor and Description |
---|
ReactorNettyTcpClient(java.util.function.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(java.lang.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<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.
|
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.
|
java.lang.String |
toString() |
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<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<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 reconnectingpublic ListenableFuture<java.lang.Void> shutdown()
TcpOperations
shutdown
in interface TcpOperations<P>
public java.lang.String toString()
toString
in class java.lang.Object