public class NettyTcpClientImpl extends NettyAbstractClient implements INettyReaderCallback<String>, NettyTcpClient<String>
It uses a single socket towards the destination. That socket is created and connected whenever the first message is sent, or after the socket was closed by the peer.
This output is blocking, that is, if the peer is slow, this output will hang so that the peer can catch up. This makes this output's input queue grow and accumulate messages.
| Modifier and Type | Class and Description |
|---|---|
static class |
NettyTcpClientImpl.Item |
| Modifier and Type | Field and Description |
|---|---|
static String |
DROP_IF_SLOW |
static boolean |
DROP_IF_SLOW_DEFAULT_VALUE |
rawbootstrap, host, maxPayloadLength, metricsContext, port, protocol, readSocketTimeoutAction, readSocketTimeoutMs, ssl, sslCiphers, sslProtocol, sslProvider, useNettyCompression| Constructor and Description |
|---|
NettyTcpClientImpl(org.thales.punch.settings.api.ISettingsMap settings,
org.thales.punch.libraries.metrics.api.IMetricContext metricsContext,
NettyDataAcker acker)
Return a new NettyTcpClient.
|
| Modifier and Type | Method and Description |
|---|---|
Class<?> |
getType() |
void |
onReceive(io.netty.channel.ChannelHandlerContext ctx,
INettyTuple<String> data)
Called when a
NettySocketServer has received data. |
NettyTcpClient<String> |
setConnectionCallback(INettyConnectionCallback cb)
Request to be told upon connection/disconnection with the target server.
|
NettyTcpClient<String> |
setName(String name)
Associate a name to the client.
|
NettyTcpClientImpl |
start()
Start the client.
|
NettyTcpClient<String> |
stop()
Stop the client.
|
String |
toString() |
boolean |
write(String data)
Write some data to the server.
|
boolean |
write(String data,
Object ctx)
Write some data to the server.
|
connect, getConnectIntervalMs, getConnectRetryIntervalMs, getSslContext, setConnectIntervalMs, setConnectRetryIntervalMs, shutdowngetFileFromString, getSslProviderclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitonActive, onInactive, onThrowablepublic static final String DROP_IF_SLOW
public static final boolean DROP_IF_SLOW_DEFAULT_VALUE
public NettyTcpClientImpl(org.thales.punch.settings.api.ISettingsMap settings,
org.thales.punch.libraries.metrics.api.IMetricContext metricsContext,
NettyDataAcker acker)
settings - the client settingsmetricsContext - the metric contextacker - the data ackerpublic NettyTcpClientImpl start()
NettyTcpClientstart in interface NettyTcpClient<String>public void onReceive(io.netty.channel.ChannelHandlerContext ctx,
INettyTuple<String> data)
INettyReaderCallbackNettySocketServer has received data.onReceive in interface INettyReaderCallback<String>ctx - the receiving channel context .data - the received data.public boolean write(String data) throws NettyException
Note that you data is not sent synchronously. When you return nothing may have happened. If the input queue is full, you can make the whole client fail or wait with the drop_if_slow
write in interface NettyTcpClient<String>data - the data to sendNettyExceptionpublic boolean write(String data, Object ctx) throws NettyException
Note that you data is not sent synchronously. When you return nothing may have happened.
write in interface NettyTcpClient<String>data - the data to sendctx - some opaque context you need for the ack or fail callback.NettyExceptionpublic NettyTcpClient<String> setConnectionCallback(INettyConnectionCallback cb)
NettyTcpClientIt can be null and will have no effect.
setConnectionCallback in interface NettyTcpClient<String>cb - the user callbackpublic NettyTcpClient<String> stop()
NettyTcpClientstop in interface NettyTcpClient<String>public NettyTcpClient<String> setName(String name)
NettyTcpClientsetName in interface NettyTcpClient<String>name - the client namepublic Class<?> getType()
getType in interface INettyReaderCallback<String>Copyright © 2023. All rights reserved.