public class ReconnectingSocket extends Object
| Constructor and Description |
|---|
ReconnectingSocket(String host,
int port) |
ReconnectingSocket(String host,
int port,
SocketFactory socketFactory) |
ReconnectingSocket(String host,
int port,
SocketFactory socketFactory,
Long connectionTimeToLiveMillis,
java.util.function.Supplier<Long> timeSupplier) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush()
Flushes the outputStream best-effort.
|
void |
write(String message)
Try to send the given message.
|
protected static final Logger logger
public ReconnectingSocket(String host, int port, SocketFactory socketFactory) throws IOException
IOException - When we cannot open the remote socket.public ReconnectingSocket(String host, int port, SocketFactory socketFactory, @Nullable Long connectionTimeToLiveMillis, @Nullable java.util.function.Supplier<Long> timeSupplier) throws IOException
host - Hostname to connect toport - Port to connect tosocketFactory - SocketFactory used to instantiate new socketsconnectionTimeToLiveMillis - Connection TTL, with expiration checked after each flush. When null,
TTL is not enforced.timeSupplier - Get current timestamp in millisIOException - When we cannot open the remote socket.public ReconnectingSocket(String host, int port) throws IOException
IOExceptionpublic void write(String message) throws Exception
Exception - when a single retry is not enough to have a successful write to the remote host.public void flush()
throws IOException
IOExceptionpublic void close()
throws IOException
IOExceptionCopyright © 2019. All rights reserved.