Class ReactorNettyTcpClient<P>
java.lang.Object
org.springframework.messaging.tcp.reactor.ReactorNettyTcpClient<P>
- Type Parameters:
- P- the type of payload for in and outbound messages
- All Implemented Interfaces:
- TcpOperations<P>
Reactor Netty based implementation of 
TcpOperations.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Stephane Maldini
- 
Constructor SummaryConstructorsConstructorDescriptionReactorNettyTcpClient(String host, int port, ReactorNettyCodec<P> codec) Simple constructor with the host and port to use to connect to.ReactorNettyTcpClient(Function<reactor.netty.tcp.TcpClient, reactor.netty.tcp.TcpClient> clientConfigurer, ReactorNettyCodec<P> codec) A variant ofReactorNettyTcpClient(String, int, ReactorNettyCodec)that still manages the lifecycle of theTcpClientand underlying resources, but allows for direct configuration of other properties of the client through aFunction<TcpClient, TcpClient>.ReactorNettyTcpClient(reactor.netty.tcp.TcpClient tcpClient, ReactorNettyCodec<P> codec) Constructor with an externally createdTcpClientinstance whose lifecycle is expected to be managed externally.
- 
Method SummaryModifier and TypeMethodDescriptionconnectAsync(TcpConnectionHandler<P> handler) Open a new connection.connectAsync(TcpConnectionHandler<P> handler, ReconnectStrategy strategy) Open a new connection and a strategy for reconnecting if the connection fails.protected reactor.netty.tcp.TcpClientextendTcpClient(reactor.netty.tcp.TcpClient tcpClient, TcpConnectionHandler<P> handler) Provides an opportunity to initialize theTcpClientfor the givenTcpConnectionHandlerwhich may implement sub-interfaces such asStompTcpConnectionHandlerthat expose further information.Return the currently configured Logger.voidSet an alternative logger to use than the one based on the class name.Shut down and close any open connections.toString()Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.messaging.tcp.TcpOperationsconnect, connect, shutdown
- 
Constructor Details- 
ReactorNettyTcpClientSimple constructor with the host and port to use to connect to.This constructor manages the lifecycle of the TcpClientand underlying resources such asConnectionProvider,LoopResources, andChannelGroup.For full control over the initialization and lifecycle of the TcpClient, use ReactorNettyTcpClient(TcpClient, ReactorNettyCodec).- Parameters:
- host- the host to connect to
- port- the port to connect to
- codec- for encoding and decoding the input/output byte streams
- See Also:
 
- 
ReactorNettyTcpClientpublic ReactorNettyTcpClient(Function<reactor.netty.tcp.TcpClient, reactor.netty.tcp.TcpClient> clientConfigurer, ReactorNettyCodec<P> codec) A variant ofReactorNettyTcpClient(String, int, ReactorNettyCodec)that still manages the lifecycle of theTcpClientand underlying resources, but allows for direct configuration of other properties of the client through aFunction<TcpClient, TcpClient>.- Parameters:
- clientConfigurer- the configurer function
- codec- for encoding and decoding the input/output byte streams
- Since:
- 5.1.3
- See Also:
 
- 
ReactorNettyTcpClientConstructor with an externally createdTcpClientinstance whose lifecycle is expected to be managed externally.- Parameters:
- tcpClient- the TcpClient instance to use
- codec- for encoding and decoding the input/output byte streams
- See Also:
 
 
- 
- 
Method Details- 
setLoggerSet an alternative logger to use than the one based on the class name.- Parameters:
- logger- the logger to use
- Since:
- 5.1
 
- 
getLoggerReturn the currently configured Logger.- Since:
- 5.1
 
- 
connectAsyncDescription copied from interface:TcpOperationsOpen a new connection.- Specified by:
- connectAsyncin interface- TcpOperations<P>
- Parameters:
- handler- a handler to manage the connection
- Returns:
- a CompletableFuture that can be used to determine when and if the connection is successfully established
 
- 
extendTcpClientprotected reactor.netty.tcp.TcpClient extendTcpClient(reactor.netty.tcp.TcpClient tcpClient, TcpConnectionHandler<P> handler) Provides an opportunity to initialize theTcpClientfor the givenTcpConnectionHandlerwhich may implement sub-interfaces such asStompTcpConnectionHandlerthat expose further information.- Parameters:
- tcpClient- the candidate TcpClient
- handler- the handler for the TCP connection
- Returns:
- the same handler or an updated instance
 
- 
connectAsyncpublic CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> handler, ReconnectStrategy strategy) Description copied from interface:TcpOperationsOpen a new connection and a strategy for reconnecting if the connection fails.- Specified by:
- connectAsyncin interface- TcpOperations<P>
- Parameters:
- handler- a handler to manage the connection
- strategy- a strategy for reconnecting
- Returns:
- a CompletableFuture that can be used to determine when and if the initial connection is successfully established
 
- 
shutdownAsyncDescription copied from interface:TcpOperationsShut down and close any open connections.- Specified by:
- shutdownAsyncin interface- TcpOperations<P>
- Returns:
- a CompletableFuture that can be used to determine when and if the connection is successfully closed
 
- 
toString
 
-