类 ReactorNettyTcpClient<P>
- java.lang.Object
- org.springframework.messaging.tcp.reactor.ReactorNettyTcpClient<P>
- 类型参数:
P- the type of payload for in and outbound messages
- 所有已实现的接口:
TcpOperations<P>
public class ReactorNettyTcpClient<P> extends Object implements TcpOperations<P>
Reactor Netty based implementation ofTcpOperations.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Stephane Maldini
构造器概要
构造器 构造器 说明 ReactorNettyTcpClient(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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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.LoggetLogger()Return the currently configured Logger.voidsetLogger(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.StringtoString()
构造器详细资料
ReactorNettyTcpClient
public ReactorNettyTcpClient(String host, int port, ReactorNettyCodec<P> codec)
Simple 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).- 参数:
host- the host to connect toport- the port to connect tocodec- for encoding and decoding the input/output byte streams- 另请参阅:
StompReactorNettyCodec
ReactorNettyTcpClient
public 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>.- 参数:
clientConfigurer- the configurer functioncodec- for encoding and decoding the input/output byte streams- 从以下版本开始:
- 5.1.3
- 另请参阅:
StompReactorNettyCodec
ReactorNettyTcpClient
public ReactorNettyTcpClient(reactor.netty.tcp.TcpClient tcpClient, ReactorNettyCodec<P> codec)
Constructor with an externally createdTcpClientinstance whose lifecycle is expected to be managed externally.- 参数:
tcpClient- the TcpClient instance to usecodec- for encoding and decoding the input/output byte streams- 另请参阅:
StompReactorNettyCodec
方法详细资料
setLogger
public void setLogger(Log logger)
Set an alternative logger to use than the one based on the class name.- 参数:
logger- the logger to use- 从以下版本开始:
- 5.1
connect
public ListenableFuture<Void> connect(TcpConnectionHandler<P> handler)
从接口复制的说明:TcpOperationsOpen a new connection.- 指定者:
connect在接口中TcpOperations<P>- 参数:
handler- a handler to manage the connection- 返回:
- a ListenableFuture that can be used to determine when and if the connection is successfully established
connect
public ListenableFuture<Void> connect(TcpConnectionHandler<P> handler, ReconnectStrategy strategy)
从接口复制的说明:TcpOperationsOpen a new connection and a strategy for reconnecting if the connection fails.- 指定者:
connect在接口中TcpOperations<P>- 参数:
handler- a handler to manage the connectionstrategy- a strategy for reconnecting- 返回:
- a ListenableFuture that can be used to determine when and if the initial connection is successfully established
shutdown
public ListenableFuture<Void> shutdown()
从接口复制的说明:TcpOperationsShut down and close any open connections.- 指定者:
shutdown在接口中TcpOperations<P>- 返回:
- a ListenableFuture that can be used to determine when and if the connection is successfully closed