类 Reactor2TcpClient<P>
- java.lang.Object
- org.springframework.messaging.tcp.reactor.Reactor2TcpClient<P>
- 所有已实现的接口:
TcpOperations<P>
public class Reactor2TcpClient<P> extends Object implements TcpOperations<P>
An implementation ofTcpOperationsbased on the TCP client support of project Reactor.This implementation wraps N Reactor
TcpClientinstances created for Nconnect(org.springframework.messaging.tcp.TcpConnectionHandler<P>)calls, i.e. once instance per connection.- 从以下版本开始:
- 4.2
- 作者:
- Rossen Stoyanchev, Stephane Maldini
字段概要
字段 修饰符和类型 字段 说明 static Class<reactor.io.net.impl.netty.tcp.NettyTcpClient>REACTOR_TCP_CLIENT_TYPE
构造器概要
构造器 构造器 说明 Reactor2TcpClient(String host, int port, reactor.io.codec.Codec<reactor.io.buffer.Buffer,Message<P>,Message<P>> codec)A constructor that creates aTcpClientSpecfactory with a defaultSynchronousDispatcher, i.e.Reactor2TcpClient(reactor.fn.Supplier<InetSocketAddress> addressSupplier, reactor.io.codec.Codec<reactor.io.buffer.Buffer,Message<P>,Message<P>> codec)A variant ofReactor2TcpClient(String, int, Codec)that takes a supplier of any number of addresses instead of just one host and port.Reactor2TcpClient(reactor.io.net.NetStreams.TcpClientFactory<Message<P>,Message<P>> tcpClientSpecFactory)A constructor with a pre-configuredSpec.TcpClientSpecFunctionfactory.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 ListenableFuture<Void>connect(TcpConnectionHandler<P> connectionHandler)Open a new connection.ListenableFuture<Void>connect(TcpConnectionHandler<P> connectionHandler, ReconnectStrategy strategy)Open a new connection and a strategy for reconnecting if the connection fails.static io.netty.channel.nio.NioEventLoopGroupinitEventLoopGroup()ListenableFuture<Void>shutdown()Shut down and close any open connections.
字段详细资料
REACTOR_TCP_CLIENT_TYPE
public static final Class<reactor.io.net.impl.netty.tcp.NettyTcpClient> REACTOR_TCP_CLIENT_TYPE
构造器详细资料
Reactor2TcpClient
public Reactor2TcpClient(String host, int port, reactor.io.codec.Codec<reactor.io.buffer.Buffer,Message<P>,Message<P>> codec)
A constructor that creates aTcpClientSpecfactory with a defaultSynchronousDispatcher, i.e. relying on Netty threads. The number of Netty threads can be tweaked with thereactor.tcp.ioThreadCountSystem property. The network I/O threads will be shared amongst the active clients.- 参数:
host- the host to connect toport- the port to connect tocodec- the codec to use for encoding and decoding the TCP stream
Reactor2TcpClient
public Reactor2TcpClient(reactor.fn.Supplier<InetSocketAddress> addressSupplier, reactor.io.codec.Codec<reactor.io.buffer.Buffer,Message<P>,Message<P>> codec)
A variant ofReactor2TcpClient(String, int, Codec)that takes a supplier of any number of addresses instead of just one host and port. This can be used toreconnectto a different address after the current host becomes unavailable.- 参数:
addressSupplier- supplier of addresses to use for connectingcodec- the codec to use for encoding and decoding the TCP stream- 从以下版本开始:
- 4.3.15
Reactor2TcpClient
public Reactor2TcpClient(reactor.io.net.NetStreams.TcpClientFactory<Message<P>,Message<P>> tcpClientSpecFactory)
A constructor with a pre-configuredSpec.TcpClientSpecFunctionfactory. This might be used to add SSL or specific network parameters to the generated client configuration.NOTE: if the client is configured with a thread-creating dispatcher, you are responsible for cleaning them, e.g. via
Resource.shutdown().- 参数:
tcpClientSpecFactory- the TcpClientSpecFunctionto use for each client creation
方法详细资料
initEventLoopGroup
public static io.netty.channel.nio.NioEventLoopGroup initEventLoopGroup()
connect
public ListenableFuture<Void> connect(TcpConnectionHandler<P> connectionHandler)
从接口复制的说明:TcpOperationsOpen a new connection.- 指定者:
connect在接口中TcpOperations<P>- 参数:
connectionHandler- 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> connectionHandler, ReconnectStrategy strategy)
从接口复制的说明:TcpOperationsOpen a new connection and a strategy for reconnecting if the connection fails.- 指定者:
connect在接口中TcpOperations<P>- 参数:
connectionHandler- 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