public class CachingClientConnectionFactory extends AbstractClientConnectionFactory implements DisposableBean
singleUse=true
in order for the connection to be
returned to the cache after use. Users should not subsequently set the underlying property to
false, or cache starvation will result.DEFAULT_REPLY_TIMEOUT, lifecycleMonitor
EXPRESSION_PARSER, logger
Constructor and Description |
---|
CachingClientConnectionFactory(AbstractClientConnectionFactory target,
int poolSize)
Construct a caching connection factory that delegates to the provided factory, with
the provided pool size.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
void |
enableManualListenerRegistration()
Set whether to automatically (default) or manually add a
TcpListener to the
connections created by this factory. |
boolean |
equals(Object o) |
void |
forceClose(TcpConnection connection)
Force close the connection and null the field if it's
a shared connection.
|
int |
getActiveCount() |
int |
getAllocatedCount() |
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
Deserializer<?> |
getDeserializer() |
String |
getHost() |
int |
getIdleCount() |
TcpMessageMapper |
getMapper() |
int |
getPoolSize() |
int |
getPort() |
TcpSender |
getSender() |
Serializer<?> |
getSerializer() |
int |
getSoLinger() |
int |
getSoReceiveBufferSize() |
int |
getSoSendBufferSize() |
int |
getSoTimeout() |
int |
getSoTrafficClass() |
int |
hashCode() |
boolean |
isLookupHost() |
boolean |
isRunning() |
boolean |
isSingleUse() |
boolean |
isSoKeepAlive() |
boolean |
isSoTcpNoDelay() |
TcpConnectionSupport |
obtainConnection() |
void |
registerListener(TcpListener listener)
Delegate TCP Client Connection factories that are used to receive
data need a Listener to send the messages to.
|
void |
registerSender(TcpSender sender)
Registers a TcpSender; for server sockets, used to
provide connection information so a sender can be used
to reply to incoming messages.
|
void |
setComponentName(String componentName)
Sets the name of this component.
|
void |
setConnectionWaitTimeout(int connectionWaitTimeout) |
void |
setDeserializer(Deserializer<?> deserializer) |
void |
setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain) |
void |
setLookupHost(boolean lookupHost)
If true, DNS reverse lookup is done on the remote ip address.
|
void |
setMapper(TcpMessageMapper mapper) |
void |
setPoolSize(int poolSize) |
void |
setSerializer(Serializer<?> serializer) |
void |
setSingleUse(boolean singleUse)
Ignored on this factory; connections are always cached in the pool.
|
void |
setSoKeepAlive(boolean soKeepAlive) |
void |
setSoLinger(int soLinger) |
void |
setSoReceiveBufferSize(int soReceiveBufferSize) |
void |
setSoSendBufferSize(int soSendBufferSize) |
void |
setSoTcpNoDelay(boolean soTcpNoDelay) |
void |
setSoTimeout(int soTimeout) |
void |
setSoTrafficClass(int soTrafficClass) |
void |
setTaskExecutor(Executor taskExecutor) |
void |
start() |
void |
stop()
Stops the server.
|
buildNewConnection, getConnection, getConnectionTest, getConnectTimeout, getTheConnection, initializeConnection, obtainNewConnection, obtainSharedConnection, setConnectionTest, setConnectTimeout, setTheConnection
addConnection, checkActive, closeConnection, delayRead, doAccept, getApplicationEventPublisher, getDelayedReads, getLifecycleMonitor, getListener, getOpenConnectionIds, getReadDelay, getSenders, getSslHandshakeTimeout, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, onInit, processNioSelections, setActive, setApplicationEventPublisher, setHost, setLeaveOpen, setNioHarvestInterval, setPort, setReadDelay, setSocketAttributes, setSslHandshakeTimeout, setTcpSocketSupport, toString, unregisterSender, wrapConnection
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler
public CachingClientConnectionFactory(AbstractClientConnectionFactory target, int poolSize)
target
- the target factory.poolSize
- the number of connections to allow.public void setConnectionWaitTimeout(int connectionWaitTimeout)
connectionWaitTimeout
- the new timeout.SimplePool.setWaitTimeout(long)
public void setPoolSize(int poolSize)
poolSize
- the new pool size.SimplePool.setPoolSize(int)
public int getPoolSize()
SimplePool.getPoolSize()
public int getIdleCount()
SimplePool.getIdleCount()
public int getActiveCount()
SimplePool.getActiveCount()
public int getAllocatedCount()
SimplePool.getAllocatedCount()
public TcpConnectionSupport obtainConnection()
obtainConnection
in class AbstractClientConnectionFactory
public boolean isRunning()
isRunning
in interface Lifecycle
isRunning
in interface ManageableLifecycle
isRunning
in class AbstractConnectionFactory
public void setComponentName(String componentName)
IntegrationObjectSupport
setComponentName
in class IntegrationObjectSupport
componentName
- The component name.public String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class IntegrationObjectSupport
public int getSoTimeout()
getSoTimeout
in class AbstractConnectionFactory
public void setSoTimeout(int soTimeout)
setSoTimeout
in class AbstractConnectionFactory
soTimeout
- the soTimeout to setpublic int getSoReceiveBufferSize()
getSoReceiveBufferSize
in class AbstractConnectionFactory
public void setSoReceiveBufferSize(int soReceiveBufferSize)
setSoReceiveBufferSize
in class AbstractConnectionFactory
soReceiveBufferSize
- the soReceiveBufferSize to setpublic int getSoSendBufferSize()
getSoSendBufferSize
in class AbstractConnectionFactory
public void setSoSendBufferSize(int soSendBufferSize)
setSoSendBufferSize
in class AbstractConnectionFactory
soSendBufferSize
- the soSendBufferSize to setpublic boolean isSoTcpNoDelay()
isSoTcpNoDelay
in class AbstractConnectionFactory
public void setSoTcpNoDelay(boolean soTcpNoDelay)
setSoTcpNoDelay
in class AbstractConnectionFactory
soTcpNoDelay
- the soTcpNoDelay to setpublic int getSoLinger()
getSoLinger
in class AbstractConnectionFactory
public void setSoLinger(int soLinger)
setSoLinger
in class AbstractConnectionFactory
soLinger
- the soLinger to setpublic boolean isSoKeepAlive()
isSoKeepAlive
in class AbstractConnectionFactory
public void setSoKeepAlive(boolean soKeepAlive)
setSoKeepAlive
in class AbstractConnectionFactory
soKeepAlive
- the soKeepAlive to setpublic int getSoTrafficClass()
getSoTrafficClass
in class AbstractConnectionFactory
public void setSoTrafficClass(int soTrafficClass)
setSoTrafficClass
in class AbstractConnectionFactory
soTrafficClass
- the soTrafficClass to setpublic String getHost()
getHost
in class AbstractConnectionFactory
public int getPort()
getPort
in class AbstractConnectionFactory
public TcpSender getSender()
getSender
in class AbstractConnectionFactory
public Serializer<?> getSerializer()
getSerializer
in class AbstractConnectionFactory
public Deserializer<?> getDeserializer()
getDeserializer
in class AbstractConnectionFactory
public TcpMessageMapper getMapper()
getMapper
in class AbstractConnectionFactory
public void registerListener(TcpListener listener)
During initialization, if a factory detects it has no listener it's listening logic (active thread) is terminated.
The listener registered with a factory is provided to each connection it creates so it can call the onMessage() method.
This code satisfies the first requirement in that this listener signals to the factory that it needs to run its listening logic.
When we wrap actual connections with CachedConnections, the connection is given the wrapper as a listener, so it can enhance the headers in onMessage(); the wrapper then invokes the real listener supplied here, with the modified message.
registerListener
in class AbstractConnectionFactory
listener
- the TcpListener.public void registerSender(TcpSender sender)
AbstractConnectionFactory
registerSender
in class AbstractConnectionFactory
sender
- The senderpublic void setTaskExecutor(Executor taskExecutor)
setTaskExecutor
in class AbstractConnectionFactory
taskExecutor
- the taskExecutor to setpublic void setDeserializer(Deserializer<?> deserializer)
setDeserializer
in class AbstractConnectionFactory
deserializer
- the deserializer to setpublic void setSerializer(Serializer<?> serializer)
setSerializer
in class AbstractConnectionFactory
serializer
- the serializer to setpublic void setMapper(TcpMessageMapper mapper)
setMapper
in class AbstractConnectionFactory
mapper
- the mapper to set; defaults to a TcpMessageMapper
public boolean isSingleUse()
isSingleUse
in class AbstractConnectionFactory
public void setSingleUse(boolean singleUse)
setSingleUse
in class AbstractConnectionFactory
singleUse
- the singleUse.public void setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain)
setInterceptorFactoryChain
in class AbstractConnectionFactory
public void setLookupHost(boolean lookupHost)
AbstractConnectionFactory
setLookupHost
in class AbstractConnectionFactory
lookupHost
- the lookupHost to setpublic boolean isLookupHost()
isLookupHost
in class AbstractConnectionFactory
public void forceClose(TcpConnection connection)
AbstractClientConnectionFactory
forceClose
in class AbstractClientConnectionFactory
connection
- The connection.public void enableManualListenerRegistration()
AbstractClientConnectionFactory
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.enableManualListenerRegistration
in class AbstractClientConnectionFactory
public void start()
start
in interface Lifecycle
start
in interface ManageableLifecycle
start
in class AbstractConnectionFactory
public void stop()
AbstractConnectionFactory
stop
in interface Lifecycle
stop
in interface ManageableLifecycle
stop
in class AbstractConnectionFactory
public void destroy() throws Exception
destroy
in interface DisposableBean
Exception