public class CachingClientConnectionFactory extends AbstractClientConnectionFactory
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| 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 |
enableManualListenerRegistration()
Set whether to automatically (default) or manually add a
TcpListener to the
connections created by this factory. |
boolean |
equals(java.lang.Object o) |
void |
forceClose(TcpConnection connection)
Force close the connection and null the field if it's
a shared connection.
|
int |
getActiveCount() |
int |
getAllocatedCount() |
java.lang.String |
getComponentType() |
org.springframework.core.serializer.Deserializer<?> |
getDeserializer() |
java.lang.String |
getHost() |
int |
getIdleCount() |
TcpMessageMapper |
getMapper() |
int |
getPoolSize() |
int |
getPort() |
TcpSender |
getSender() |
org.springframework.core.serializer.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(java.lang.String componentName) |
void |
setConnectionWaitTimeout(int connectionWaitTimeout) |
void |
setDeserializer(org.springframework.core.serializer.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(org.springframework.core.serializer.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(java.util.concurrent.Executor taskExecutor) |
void |
start() |
void |
stop()
Stops the server.
|
buildNewConnection, getConnection, getTheConnection, initializeConnection, obtainNewConnection, obtainSharedConnection, setTheConnectionaddConnection, checkActive, closeConnection, delayRead, doAccept, getApplicationEventPublisher, getDelayedReads, getListener, getOpenConnectionIds, getReadDelay, getSslHandshakeTimeout, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, onInit, processNioSelections, setActive, setApplicationEventPublisher, setHost, setLeaveOpen, setNioHarvestInterval, setPort, setReadDelay, setSocketAttributes, setSslHandshakeTimeout, setTcpSocketSupport, toString, wrapConnectionafterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskSchedulerpublic 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() throws java.lang.Exception
obtainConnection in class AbstractClientConnectionFactoryjava.lang.Exceptionpublic boolean isRunning()
isRunning in interface org.springframework.context.LifecycleisRunning in class AbstractConnectionFactorypublic int hashCode()
hashCode in class java.lang.Objectpublic void setComponentName(java.lang.String componentName)
setComponentName in class org.springframework.integration.context.IntegrationObjectSupportpublic java.lang.String getComponentType()
getComponentType in interface org.springframework.integration.support.context.NamedComponentgetComponentType in class org.springframework.integration.context.IntegrationObjectSupportpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int getSoTimeout()
getSoTimeout in class AbstractConnectionFactorypublic void setSoTimeout(int soTimeout)
setSoTimeout in class AbstractConnectionFactorysoTimeout - the soTimeout to setpublic int getSoReceiveBufferSize()
getSoReceiveBufferSize in class AbstractConnectionFactorypublic void setSoReceiveBufferSize(int soReceiveBufferSize)
setSoReceiveBufferSize in class AbstractConnectionFactorysoReceiveBufferSize - the soReceiveBufferSize to setpublic int getSoSendBufferSize()
getSoSendBufferSize in class AbstractConnectionFactorypublic void setSoSendBufferSize(int soSendBufferSize)
setSoSendBufferSize in class AbstractConnectionFactorysoSendBufferSize - the soSendBufferSize to setpublic boolean isSoTcpNoDelay()
isSoTcpNoDelay in class AbstractConnectionFactorypublic void setSoTcpNoDelay(boolean soTcpNoDelay)
setSoTcpNoDelay in class AbstractConnectionFactorysoTcpNoDelay - the soTcpNoDelay to setpublic int getSoLinger()
getSoLinger in class AbstractConnectionFactorypublic void setSoLinger(int soLinger)
setSoLinger in class AbstractConnectionFactorysoLinger - the soLinger to setpublic boolean isSoKeepAlive()
isSoKeepAlive in class AbstractConnectionFactorypublic void setSoKeepAlive(boolean soKeepAlive)
setSoKeepAlive in class AbstractConnectionFactorysoKeepAlive - the soKeepAlive to setpublic int getSoTrafficClass()
getSoTrafficClass in class AbstractConnectionFactorypublic void setSoTrafficClass(int soTrafficClass)
setSoTrafficClass in class AbstractConnectionFactorysoTrafficClass - the soTrafficClass to setpublic java.lang.String getHost()
getHost in class AbstractConnectionFactorypublic int getPort()
getPort in class AbstractConnectionFactorypublic TcpSender getSender()
getSender in class AbstractConnectionFactorypublic org.springframework.core.serializer.Serializer<?> getSerializer()
getSerializer in class AbstractConnectionFactorypublic org.springframework.core.serializer.Deserializer<?> getDeserializer()
getDeserializer in class AbstractConnectionFactorypublic TcpMessageMapper getMapper()
getMapper in class AbstractConnectionFactorypublic 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 AbstractConnectionFactorylistener - the TcpListener.public void registerSender(TcpSender sender)
AbstractConnectionFactoryregisterSender in class AbstractConnectionFactorysender - The senderpublic void setTaskExecutor(java.util.concurrent.Executor taskExecutor)
setTaskExecutor in class AbstractConnectionFactorytaskExecutor - the taskExecutor to setpublic void setDeserializer(org.springframework.core.serializer.Deserializer<?> deserializer)
setDeserializer in class AbstractConnectionFactorydeserializer - the deserializer to setpublic void setSerializer(org.springframework.core.serializer.Serializer<?> serializer)
setSerializer in class AbstractConnectionFactoryserializer - the serializer to setpublic void setMapper(TcpMessageMapper mapper)
setMapper in class AbstractConnectionFactorymapper - the mapper to set; defaults to a TcpMessageMapperpublic boolean isSingleUse()
isSingleUse in class AbstractConnectionFactorypublic void setSingleUse(boolean singleUse)
setSingleUse in class AbstractConnectionFactorysingleUse - the singleUse.public void setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain)
setInterceptorFactoryChain in class AbstractConnectionFactorypublic void setLookupHost(boolean lookupHost)
AbstractConnectionFactorysetLookupHost in class AbstractConnectionFactorylookupHost - the lookupHost to setpublic boolean isLookupHost()
isLookupHost in class AbstractConnectionFactorypublic void forceClose(TcpConnection connection)
AbstractClientConnectionFactoryforceClose in class AbstractClientConnectionFactoryconnection - The connection.public void enableManualListenerRegistration()
AbstractClientConnectionFactoryTcpListener 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 AbstractClientConnectionFactorypublic void start()
start in interface org.springframework.context.Lifecyclestart in class AbstractConnectionFactorypublic void stop()
AbstractConnectionFactorystop in interface org.springframework.context.Lifecyclestop in class AbstractConnectionFactory