org.springframework.messaging.tcp.reactor

## 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>

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

Reactor Netty based implementation of `TcpOperations`.

Since:
  5.0
Author:
  Rossen Stoyanchev, Stephane Maldini

### Constructor Summary

Constructors
Constructor and Description
`ReactorNettyTcpClient(Function<reactor.netty.tcp.TcpClient,reactor.netty.tcp.TcpClient> clientConfigurer, ReactorNettyCodec<P> codec)` A variant of `ReactorNettyTcpClient(String, int, ReactorNettyCodec)` that still manages the lifecycle of the `TcpClient` and underlying resources, but allows for direct configuration of other properties of the client through a `Function<TcpClient, TcpClient>`.
`ReactorNettyTcpClient(String host, int port, ReactorNettyCodec<P> codec)` Simple constructor with the host and port to use to connect to.
`ReactorNettyTcpClient(reactor.netty.tcp.TcpClient tcpClient, ReactorNettyCodec<P> codec)` Constructor with an externally created `TcpClient` instance whose lifecycle is expected to be managed externally.

### Method Summary

All Methods Instance Methods Concrete Methods
`org.springframework.util.concurrent.ListenableFuture<Void>` `connect(TcpConnectionHandler<P> handler)` Open a new connection.
`org.springframework.util.concurrent.ListenableFuture<Void>` `connect(TcpConnectionHandler<P> handler, ReconnectStrategy strategy)` Open a new connection and a strategy for reconnecting if the connection fails.
`Log` `getLogger()` Return the currently configured Logger.
`void` `setLogger(Log logger)` Set an alternative logger to use than the one based on the class name.
`org.springframework.util.concurrent.ListenableFuture<Void>` `shutdown()` Shut down and close any open connections.
`String` `toString()`

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

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

### Constructor Detail

#### 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 `TcpClient` and underlying resources such as `ConnectionProvider`, `LoopResources`, and `ChannelGroup`.

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:
  `StompReactorNettyCodec`

#### ReactorNettyTcpClient

    public ReactorNettyTcpClient(Function<reactor.netty.tcp.TcpClient,reactor.netty.tcp.TcpClient> clientConfigurer,
                                 ReactorNettyCodec<P> codec)

A variant of `ReactorNettyTcpClient(String, int, ReactorNettyCodec)` that still manages the lifecycle of the `TcpClient` and underlying resources, but allows for direct configuration of other properties of the client through a `Function<TcpClient, TcpClient>`.

Parameters:
  `clientConfigurer` - the configurer function
  `codec` - for encoding and decoding the input/output byte streams
Since:
  5.1.3
See Also:
  `StompReactorNettyCodec`

#### ReactorNettyTcpClient

    public ReactorNettyTcpClient(reactor.netty.tcp.TcpClient tcpClient,
                                 ReactorNettyCodec<P> codec)

Constructor with an externally created `TcpClient` instance 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:
  `StompReactorNettyCodec`

### Method Detail

#### setLogger

    public void setLogger(Log logger)

Set an alternative logger to use than the one based on the class name.

Parameters:
  `logger` - the logger to use
Since:
  5.1

#### getLogger

    public Log getLogger()

Return the currently configured Logger.

Since:
  5.1

#### connect

    public org.springframework.util.concurrent.ListenableFuture<Void> connect(TcpConnectionHandler<P> handler)

Description copied from interface: `TcpOperations`
Open a new connection.

Specified by:
  `connect` in interface `TcpOperations<P>`
Parameters:
  `handler` - 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 org.springframework.util.concurrent.ListenableFuture<Void> connect(TcpConnectionHandler<P> handler,
                                                                              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:
  `handler` - 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

#### shutdown

    public org.springframework.util.concurrent.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

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`