org.springframework.messaging.tcp.reactor

## Class ReactorTcpClient<P>

- java.lang.Object
- - org.springframework.messaging.tcp.reactor.ReactorTcpClient<P>

- All Implemented Interfaces:
    TcpOperations<P>

      public class ReactorTcpClient<P>
      extends Object
      implements TcpOperations<P>

  An implementation of `TcpOperations` based on the TCP client support of the Reactor project.
  Since:
    4.0
  Author:
    Rossen Stoyanchev

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Class<reactor.tcp.netty.NettyTcpClient>` | `REACTOR_TCP_CLIENT_TYPE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReactorTcpClient(String host, int port, reactor.tcp.encoding.Codec<reactor.io.Buffer,Message<P>,Message<P>> codec)` A constructor that creates a `NettyTcpClient` with a `reactor.event.dispatch.SynchronousDispatcher` as a result of which network I/O is handled in Netty threads.
    `ReactorTcpClient(reactor.tcp.TcpClient<Message<P>,Message<P>> tcpClient)` A constructor with a pre-configured `TcpClient`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ListenableFuture<Void>` | `connect(TcpConnectionHandler<P> connectionHandler)` Open a new connection.
    `ListenableFuture<Void>` | `connect(TcpConnectionHandler<P> connectionHandler, ReconnectStrategy reconnectStrategy)` Open a new connection and a strategy for reconnecting if the connection fails.
    `ListenableFuture<Void>` | `shutdown()` Shut down and close any open connections.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### REACTOR_TCP_CLIENT_TYPE

          public static final Class<reactor.tcp.netty.NettyTcpClient> REACTOR_TCP_CLIENT_TYPE

  - ### Constructor Detail

    - #### ReactorTcpClient

          public ReactorTcpClient(String host,
                                  int port,
                                  reactor.tcp.encoding.Codec<reactor.io.Buffer,Message<P>,Message<P>> codec)

      A constructor that creates a `NettyTcpClient` with a `reactor.event.dispatch.SynchronousDispatcher` as a result of which network I/O is handled in Netty threads.

      Also see the constructor accepting a pre-configured Reactor `TcpClient`.

      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

    - #### ReactorTcpClient

          public ReactorTcpClient(reactor.tcp.TcpClient<Message<P>,Message<P>> tcpClient)

      A constructor with a pre-configured `TcpClient`.

      NOTE: if the client is configured with a thread-creating dispatcher, you are responsible for shutting down the `Environment` instance with which the client is configured.

      Parameters:
        `tcpClient` - the TcpClient to use

  - ### Method Detail

    - #### connect

          public ListenableFuture<Void> connect(TcpConnectionHandler<P> connectionHandler)

      Description copied from interface: `TcpOperations`
      Open a new connection.
      Specified by:
        `connect` in interface `TcpOperations<P>`
      Parameters:
        `connectionHandler` - a handler to manage the connection
      Returns:
        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 reconnectStrategy)

      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
        `reconnectStrategy` - a strategy for reconnecting
      Returns:
        a ListenableFuture that can be used to determine when and if the initial connection is successfully established

    - #### shutdown

          public ListenableFuture<Void> shutdown()

      Description copied from interface: `TcpOperations`
      Shut down and close any open connections.
      Specified by:
        `shutdown` in interface `TcpOperations<P>`
      Returns:
        a ListenableFuture that can be used to determine when and if the connection is successfully closed