Class Reactor2TcpClient<P>

    • Constructor Detail

      • Reactor2TcpClient

        public Reactor2TcpClient​(String host,
                                 int port,
                                 reactor.io.codec.Codec<reactor.io.buffer.Buffer,​Message<P>,​Message<P>> codec)
        A constructor that creates a TcpClientSpec factory with a default SynchronousDispatcher, i.e. relying on Netty threads. The number of Netty threads can be tweaked with the reactor.tcp.ioThreadCount System property. The network I/O threads will be shared amongst the active clients.
        Parameters:
        host - the host to connect to
        port - the port to connect to
        codec - 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 of Reactor2TcpClient(String, int, Codec) that takes a supplier of any number of addresses instead of just one host and port. This can be used to reconnect to a different address after the current host becomes unavailable.
        Parameters:
        addressSupplier - supplier of addresses to use for connecting
        codec - the codec to use for encoding and decoding the TCP stream
        Since:
        4.3.15
      • Reactor2TcpClient

        public Reactor2TcpClient​(reactor.io.net.NetStreams.TcpClientFactory<Message<P>,​Message<P>> tcpClientSpecFactory)
        A constructor with a pre-configured Spec.TcpClientSpecFunction factory. 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().

        Parameters:
        tcpClientSpecFactory - the TcpClientSpec Function to use for each client creation
    • Method Detail

      • initEventLoopGroup

        public static io.netty.channel.nio.NioEventLoopGroup initEventLoopGroup()
      • connect

        public ListenableFuture<Voidconnect​(TcpConnectionHandler<P> connectionHandler,
                                              ReconnectStrategy strategy)
        Description copied from interface: TcpOperations
        Open a new connection and a strategy for reconnecting if the connection fails.
        Specified by:
        connect in interface TcpOperations<P>
        Parameters:
        connectionHandler - a handler to manage the connection
        strategy - a strategy for reconnecting
        Returns:
        a ListenableFuture that can be used to determine when and if the initial connection is successfully established