Class ThreadAffinityClientConnectionFactory
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory
org.springframework.integration.ip.tcp.connection.ThreadAffinityClientConnectionFactory
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- InitializingBean,- ApplicationContextAware,- ApplicationEventPublisherAware,- Lifecycle,- ComponentSourceAware,- ExpressionCapable,- ConnectionFactory,- NamedComponent,- ManageableLifecycle
A client connection factory that binds a connection to a thread. Close operations
 are ignored; to physically close a connection and release the thread local, invoke
 
releaseConnection().- Since:
- 5.0
- Author:
- Gary Russell
- 
Field SummaryFields inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactoryconnectionsMonitor, DEFAULT_REPLY_TIMEOUT, lifecycleMonitorFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, logger
- 
Constructor SummaryConstructorsConstructorDescriptionThreadAffinityClientConnectionFactory(AbstractClientConnectionFactory connectionFactory) 
- 
Method SummaryModifier and TypeMethodDescriptionbooleancloseConnection(String connectionId) Close a connection with the specified connection id.voidSet whether to automatically (default) or manually add aTcpListenerto the connections created by this factory.voidforceClose(TcpConnection connection) Force close the connection and null the field if it's a shared connection.Returns theApplicationContext.getId()if theApplicationContextis available.Will return the name of this component identified byIntegrationObjectSupport.componentNamefield.Subclasses may implement this method to provide component type information.Obtain a connection - ifAbstractConnectionFactory.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.Deserializer<?> Return the primary SpEL expression if this component is expression-based.getHost()Returns a list of (currently) openTcpConnectionconnection ids; allows, for example, broadcast operations to all open connections.intgetPort()Return the list of senders.Serializer<?> intintintintintbooleanbooleanbooleanbooleanvoidregisterListener(TcpListener listener) Registers a TcpListener to receive messages after the payload has been converted from the input data.voidregisterSender(TcpSender sender) Registers a TcpSender; for server sockets, used to provide connection information so a sender can be used to reply to incoming messages.voidvoidsetApplicationContext(ApplicationContext applicationContext) voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetBeanFactory(BeanFactory beanFactory) voidsetChannelResolver(DestinationResolver<MessageChannel> channelResolver) Specify theDestinationResolverstrategy to use.voidsetComponentName(String componentName) Sets the name of this component.voidsetDeserializer(Deserializer<?> deserializer) voidSet the host; requires the factory to be stopped.voidsetInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain) voidsetLookupHost(boolean lookupHost) If true, DNS reverse lookup is done on the remote ip address.voidsetMapper(TcpMessageMapper mapper) voidsetMessageBuilderFactory(MessageBuilderFactory messageBuilderFactory) voidsetNioHarvestInterval(int nioHarvestInterval) How often we clean up closed NIO connections if soTimeout is 0.voidsetPort(int port) Set the port; requires the factory to be stopped.voidsetReadDelay(long readDelay) The delay (in milliseconds) before retrying a read after the previous attempt failed due to insufficient threads.voidsetSerializer(Serializer<?> serializer) voidsetSoKeepAlive(boolean soKeepAlive) voidsetSoLinger(int soLinger) voidsetSoReceiveBufferSize(int soReceiveBufferSize) voidsetSoSendBufferSize(int soSendBufferSize) voidsetSoTcpNoDelay(boolean soTcpNoDelay) voidsetSoTimeout(int soTimeout) voidsetSoTrafficClass(int soTrafficClass) voidsetSslHandshakeTimeout(int sslHandshakeTimeout) Set the handshake timeout used when waiting for SSL handshake data; only applies to SSL connections, when using NIO.voidsetTaskExecutor(Executor taskExecutor) voidsetTcpSocketSupport(TcpSocketSupport tcpSocketSupport) voidstart()voidstop()Stops the server.toString()Methods inherited from class org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactorybuildNewConnection, getConnectionTest, getConnectTimeout, getTheConnection, initializeConnection, obtainConnection, obtainNewConnection, obtainSharedConnection, setConnectionTest, setConnectTimeout, setTheConnectionMethods inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactoryaddConnection, checkActive, delayRead, doAccept, getDelayedReads, getLifecycleMonitor, getReadDelay, getSslHandshakeTimeout, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, isSingleUse, onInit, processNioSelections, setActive, setLeaveOpen, setSingleUse, setSocketAttributes, unregisterSender, wrapConnectionMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentSource, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setBeanName, setComponentDescription, setComponentSource, setConversionService, setPrimaryExpression, setTaskScheduler
- 
Constructor Details- 
ThreadAffinityClientConnectionFactory
 
- 
- 
Method Details- 
getConnectionDescription copied from class:AbstractClientConnectionFactoryObtain a connection - ifAbstractConnectionFactory.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.- Specified by:
- getConnectionin interface- ConnectionFactory
- Overrides:
- getConnectionin class- AbstractClientConnectionFactory
- Throws:
- InterruptedException- if interrupted.
 
- 
releaseConnectionpublic void releaseConnection()
- 
enableManualListenerRegistrationpublic void enableManualListenerRegistration()Description copied from class:AbstractClientConnectionFactorySet whether to automatically (default) or manually add aTcpListenerto 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.- Overrides:
- enableManualListenerRegistrationin class- AbstractClientConnectionFactory
 
- 
getComponentNameDescription copied from class:IntegrationObjectSupportWill return the name of this component identified byIntegrationObjectSupport.componentNamefield. IfIntegrationObjectSupport.componentNamewas not set this method will default to the 'beanName' of this component;- Specified by:
- getComponentNamein interface- NamedComponent
- Overrides:
- getComponentNamein class- IntegrationObjectSupport
 
- 
setComponentNameDescription copied from class:IntegrationObjectSupportSets the name of this component.- Overrides:
- setComponentNamein class- IntegrationObjectSupport
- Parameters:
- componentName- The component name.
 
- 
setApplicationEventPublisher- Specified by:
- setApplicationEventPublisherin interface- ApplicationEventPublisherAware
- Overrides:
- setApplicationEventPublisherin class- AbstractConnectionFactory
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- IntegrationObjectSupport
 
- 
setBeanFactory- Specified by:
- setBeanFactoryin interface- BeanFactoryAware
- Overrides:
- setBeanFactoryin class- IntegrationObjectSupport
 
- 
setApplicationContext- Specified by:
- setApplicationContextin interface- ApplicationContextAware
- Overrides:
- setApplicationContextin class- IntegrationObjectSupport
- Throws:
- BeansException
 
- 
getApplicationEventPublisher- Overrides:
- getApplicationEventPublisherin class- AbstractConnectionFactory
 
- 
setChannelResolverDescription copied from class:IntegrationObjectSupportSpecify theDestinationResolverstrategy to use. The default is a BeanFactoryChannelResolver.- Overrides:
- setChannelResolverin class- IntegrationObjectSupport
- Parameters:
- channelResolver- The channel resolver.
 
- 
getExpressionDescription copied from interface:ExpressionCapableReturn the primary SpEL expression if this component is expression-based.- Specified by:
- getExpressionin interface- ExpressionCapable
- Overrides:
- getExpressionin class- IntegrationObjectSupport
- Returns:
- the expression as a String.
 
- 
forceCloseDescription copied from class:AbstractClientConnectionFactoryForce close the connection and null the field if it's a shared connection.- Overrides:
- forceClosein class- AbstractClientConnectionFactory
- Parameters:
- connection- The connection.
 
- 
getSoTimeoutpublic int getSoTimeout()- Overrides:
- getSoTimeoutin class- AbstractConnectionFactory
- Returns:
- the soTimeout
 
- 
setSoTimeoutpublic void setSoTimeout(int soTimeout) - Overrides:
- setSoTimeoutin class- AbstractConnectionFactory
- Parameters:
- soTimeout- the soTimeout to set, in milliseconds
 
- 
getSoReceiveBufferSizepublic int getSoReceiveBufferSize()- Overrides:
- getSoReceiveBufferSizein class- AbstractConnectionFactory
- Returns:
- the soReceiveBufferSize
 
- 
setSoReceiveBufferSizepublic void setSoReceiveBufferSize(int soReceiveBufferSize) - Overrides:
- setSoReceiveBufferSizein class- AbstractConnectionFactory
- Parameters:
- soReceiveBufferSize- the soReceiveBufferSize to set
 
- 
getSoSendBufferSizepublic int getSoSendBufferSize()- Overrides:
- getSoSendBufferSizein class- AbstractConnectionFactory
- Returns:
- the soSendBufferSize
 
- 
setSoSendBufferSizepublic void setSoSendBufferSize(int soSendBufferSize) - Overrides:
- setSoSendBufferSizein class- AbstractConnectionFactory
- Parameters:
- soSendBufferSize- the soSendBufferSize to set
 
- 
isSoTcpNoDelaypublic boolean isSoTcpNoDelay()- Overrides:
- isSoTcpNoDelayin class- AbstractConnectionFactory
- Returns:
- the soTcpNoDelay
 
- 
setSoTcpNoDelaypublic void setSoTcpNoDelay(boolean soTcpNoDelay) - Overrides:
- setSoTcpNoDelayin class- AbstractConnectionFactory
- Parameters:
- soTcpNoDelay- the soTcpNoDelay to set
 
- 
getSoLingerpublic int getSoLinger()- Overrides:
- getSoLingerin class- AbstractConnectionFactory
- Returns:
- the soLinger
 
- 
setSoLingerpublic void setSoLinger(int soLinger) - Overrides:
- setSoLingerin class- AbstractConnectionFactory
- Parameters:
- soLinger- the soLinger to set
 
- 
isSoKeepAlivepublic boolean isSoKeepAlive()- Overrides:
- isSoKeepAlivein class- AbstractConnectionFactory
- Returns:
- the soKeepAlive
 
- 
setSoKeepAlivepublic void setSoKeepAlive(boolean soKeepAlive) - Overrides:
- setSoKeepAlivein class- AbstractConnectionFactory
- Parameters:
- soKeepAlive- the soKeepAlive to set
 
- 
getConversionService- Overrides:
- getConversionServicein class- IntegrationObjectSupport
 
- 
getSoTrafficClasspublic int getSoTrafficClass()- Overrides:
- getSoTrafficClassin class- AbstractConnectionFactory
- Returns:
- the soTrafficClass
 
- 
setSoTrafficClasspublic void setSoTrafficClass(int soTrafficClass) - Overrides:
- setSoTrafficClassin class- AbstractConnectionFactory
- Parameters:
- soTrafficClass- the soTrafficClass to set
 
- 
setHostDescription copied from class:AbstractConnectionFactorySet the host; requires the factory to be stopped.- Overrides:
- setHostin class- AbstractConnectionFactory
- Parameters:
- host- the host.
 
- 
getHost- Overrides:
- getHostin class- AbstractConnectionFactory
- Returns:
- the host
 
- 
setPortpublic void setPort(int port) Description copied from class:AbstractConnectionFactorySet the port; requires the factory to be stopped.- Overrides:
- setPortin class- AbstractConnectionFactory
- Parameters:
- port- the port.
 
- 
getApplicationContextIdDescription copied from class:IntegrationObjectSupportReturns theApplicationContext.getId()if theApplicationContextis available.- Overrides:
- getApplicationContextIdin class- IntegrationObjectSupport
- Returns:
- The id, or null if there is no application context.
 
- 
getPortpublic int getPort()- Overrides:
- getPortin class- AbstractConnectionFactory
- Returns:
- the port
 
- 
getListener- Overrides:
- getListenerin class- AbstractConnectionFactory
- Returns:
- the listener
 
- 
getSender- Overrides:
- getSenderin class- AbstractConnectionFactory
- Returns:
- the first sender, if present.
 
- 
getSendersDescription copied from class:AbstractConnectionFactoryReturn the list of senders.- Overrides:
- getSendersin class- AbstractConnectionFactory
- Returns:
- the senders.
 
- 
getSerializer- Overrides:
- getSerializerin class- AbstractConnectionFactory
- Returns:
- the serializer
 
- 
getDeserializer- Overrides:
- getDeserializerin class- AbstractConnectionFactory
- Returns:
- the deserializer
 
- 
getMapper- Overrides:
- getMapperin class- AbstractConnectionFactory
- Returns:
- the mapper
 
- 
registerListenerDescription copied from class:AbstractConnectionFactoryRegisters a TcpListener to receive messages after the payload has been converted from the input data.- Overrides:
- registerListenerin class- AbstractConnectionFactory
- Parameters:
- listener- the TcpListener.
 
- 
setMessageBuilderFactory- Overrides:
- setMessageBuilderFactoryin class- IntegrationObjectSupport
 
- 
registerSenderDescription copied from class:AbstractConnectionFactoryRegisters a TcpSender; for server sockets, used to provide connection information so a sender can be used to reply to incoming messages.- Overrides:
- registerSenderin class- AbstractConnectionFactory
- Parameters:
- sender- The sender
 
- 
setTaskExecutor- Overrides:
- setTaskExecutorin class- AbstractConnectionFactory
- Parameters:
- taskExecutor- the taskExecutor to set
 
- 
setDeserializer- Overrides:
- setDeserializerin class- AbstractConnectionFactory
- Parameters:
- deserializer- the deserializer to set
 
- 
setSerializer- Overrides:
- setSerializerin class- AbstractConnectionFactory
- Parameters:
- serializer- the serializer to set
 
- 
setMapper- Overrides:
- setMapperin class- AbstractConnectionFactory
- Parameters:
- mapper- the mapper to set; defaults to a- TcpMessageMapper
 
- 
setInterceptorFactoryChainpublic void setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain) - Overrides:
- setInterceptorFactoryChainin class- AbstractConnectionFactory
 
- 
setLookupHostpublic void setLookupHost(boolean lookupHost) Description copied from class:AbstractConnectionFactoryIf true, DNS reverse lookup is done on the remote ip address. Default false: not all environments (e.g. Docker containers) perform reliable DNS resolution.- Overrides:
- setLookupHostin class- AbstractConnectionFactory
- Parameters:
- lookupHost- the lookupHost to set
 
- 
isLookupHostpublic boolean isLookupHost()- Overrides:
- isLookupHostin class- AbstractConnectionFactory
- Returns:
- the lookupHost
 
- 
setNioHarvestIntervalpublic void setNioHarvestInterval(int nioHarvestInterval) Description copied from class:AbstractConnectionFactoryHow often we clean up closed NIO connections if soTimeout is 0. Ignored whensoTimeout > 0because the clean up process is run as part of the timeout handling. Default 2000 milliseconds.- Overrides:
- setNioHarvestIntervalin class- AbstractConnectionFactory
- Parameters:
- nioHarvestInterval- The interval in milliseconds.
 
- 
setSslHandshakeTimeoutpublic void setSslHandshakeTimeout(int sslHandshakeTimeout) Description copied from class:AbstractConnectionFactorySet the handshake timeout used when waiting for SSL handshake data; only applies to SSL connections, when using NIO.- Overrides:
- setSslHandshakeTimeoutin class- AbstractConnectionFactory
- Parameters:
- sslHandshakeTimeout- the timeout.
 
- 
setReadDelaypublic void setReadDelay(long readDelay) Description copied from class:AbstractConnectionFactoryThe delay (in milliseconds) before retrying a read after the previous attempt failed due to insufficient threads. Default 100.- Overrides:
- setReadDelayin class- AbstractConnectionFactory
- Parameters:
- readDelay- the readDelay to set.
 
- 
startpublic void start()- Specified by:
- startin interface- Lifecycle
- Specified by:
- startin interface- ManageableLifecycle
- Overrides:
- startin class- AbstractConnectionFactory
 
- 
stoppublic void stop()Description copied from class:AbstractConnectionFactoryStops the server.- Specified by:
- stopin interface- Lifecycle
- Specified by:
- stopin interface- ManageableLifecycle
- Overrides:
- stopin class- AbstractConnectionFactory
 
- 
isRunningpublic boolean isRunning()- Specified by:
- isRunningin interface- Lifecycle
- Specified by:
- isRunningin interface- ManageableLifecycle
- Overrides:
- isRunningin class- AbstractConnectionFactory
 
- 
setTcpSocketSupport- Overrides:
- setTcpSocketSupportin class- AbstractConnectionFactory
 
- 
getOpenConnectionIdsDescription copied from class:AbstractConnectionFactoryReturns a list of (currently) openTcpConnectionconnection ids; allows, for example, broadcast operations to all open connections.- Overrides:
- getOpenConnectionIdsin class- AbstractConnectionFactory
- Returns:
- the list of connection ids.
 
- 
closeConnectionDescription copied from class:AbstractConnectionFactoryClose a connection with the specified connection id.- Overrides:
- closeConnectionin class- AbstractConnectionFactory
- Parameters:
- connectionId- the connection id.
- Returns:
- true if the connection was closed.
 
- 
toString- Overrides:
- toStringin class- AbstractConnectionFactory
 
 
-