public abstract class AbstractClientConnectionFactory extends AbstractConnectionFactory
DEFAULT_REPLY_TIMEOUT, lifecycleMonitor
EXPRESSION_PARSER, logger
Constructor and Description |
---|
AbstractClientConnectionFactory(String host,
int port)
Constructs a factory that will established connections to the host and port.
|
Modifier and Type | Method and Description |
---|---|
protected TcpConnectionSupport |
buildNewConnection() |
void |
enableManualListenerRegistration()
Set whether to automatically (default) or manually add a
TcpListener to the
connections created by this factory. |
void |
forceClose(TcpConnection connection)
Force close the connection and null the field if it's
a shared connection.
|
TcpConnectionSupport |
getConnection()
Obtains a connection - if
AbstractConnectionFactory.setSingleUse(boolean) was called with
true, a new connection is returned; otherwise a single connection is
reused for all requests while the connection remains open. |
protected java.util.function.Predicate<TcpConnectionSupport> |
getConnectionTest()
Get a
Predicate that will be invoked to test a new connection; return true
to accept the connection, false the reject. |
protected java.time.Duration |
getConnectTimeout() |
protected TcpConnectionSupport |
getTheConnection() |
protected void |
initializeConnection(TcpConnectionSupport connection,
Socket socket)
Transfers attributes such as (de)serializers, singleUse etc to a new connection.
|
protected TcpConnectionSupport |
obtainConnection() |
protected TcpConnectionSupport |
obtainNewConnection() |
protected TcpConnectionSupport |
obtainSharedConnection() |
void |
setConnectionTest(java.util.function.Predicate<TcpConnectionSupport> connectionTest)
Set a
Predicate that will be invoked to test a new connection; return true
to accept the connection, false the reject. |
void |
setConnectTimeout(int connectTimeout)
Set the connection timeout in seconds.
|
protected void |
setTheConnection(TcpConnectionSupport theConnection) |
addConnection, checkActive, closeConnection, delayRead, doAccept, getApplicationEventPublisher, getDelayedReads, getDeserializer, getHost, getLifecycleMonitor, getListener, getMapper, getOpenConnectionIds, getPort, getReadDelay, getSender, getSenders, getSerializer, getSoLinger, getSoReceiveBufferSize, getSoSendBufferSize, getSoTimeout, getSoTrafficClass, getSslHandshakeTimeout, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, isLookupHost, isRunning, isSingleUse, isSoKeepAlive, isSoTcpNoDelay, onInit, processNioSelections, registerListener, registerSender, setActive, setApplicationEventPublisher, setDeserializer, setHost, setInterceptorFactoryChain, setLeaveOpen, setLookupHost, setMapper, setNioHarvestInterval, setPort, setReadDelay, setSerializer, setSingleUse, setSocketAttributes, setSoKeepAlive, setSoLinger, setSoReceiveBufferSize, setSoSendBufferSize, setSoTcpNoDelay, setSoTimeout, setSoTrafficClass, setSslHandshakeTimeout, setTaskExecutor, setTcpSocketSupport, start, stop, toString, unregisterSender, wrapConnection
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler
public AbstractClientConnectionFactory(String host, int port)
host
- The host.port
- The port.public void setConnectTimeout(int connectTimeout)
connectTimeout
- the timeout.protected java.time.Duration getConnectTimeout()
public void enableManualListenerRegistration()
TcpListener
to the
connections created by this factory. By default, the factory automatically configures
the listener. When manual registration is in place, incoming messages will be delayed
until the listener is registered.@Nullable protected java.util.function.Predicate<TcpConnectionSupport> getConnectionTest()
Predicate
that will be invoked to test a new connection; return true
to accept the connection, false the reject.public void setConnectionTest(@Nullable java.util.function.Predicate<TcpConnectionSupport> connectionTest)
Predicate
that will be invoked to test a new connection; return true
to accept the connection, false the reject.connectionTest
- the predicate.public TcpConnectionSupport getConnection() throws InterruptedException
AbstractConnectionFactory.setSingleUse(boolean)
was called with
true, a new connection is returned; otherwise a single connection is
reused for all requests while the connection remains open.InterruptedException
- if interrupted.protected TcpConnectionSupport obtainConnection() throws InterruptedException
InterruptedException
@Nullable protected final TcpConnectionSupport obtainSharedConnection() throws InterruptedException
InterruptedException
protected final TcpConnectionSupport obtainNewConnection() throws InterruptedException
InterruptedException
protected TcpConnectionSupport buildNewConnection()
protected void initializeConnection(TcpConnectionSupport connection, Socket socket)
connection
- The new connection.socket
- The new socket.protected void setTheConnection(TcpConnectionSupport theConnection)
theConnection
- the theConnection to set@Nullable protected TcpConnectionSupport getTheConnection()
public void forceClose(TcpConnection connection)
connection
- The connection.