public class ThreadAffinityClientConnectionFactory extends AbstractClientConnectionFactory
releaseConnection()
.DEFAULT_REPLY_TIMEOUT, lifecycleMonitor
EXPRESSION_PARSER, logger
Constructor and Description |
---|
ThreadAffinityClientConnectionFactory(AbstractClientConnectionFactory connectionFactory) |
Modifier and Type | Method and Description |
---|---|
boolean |
closeConnection(String connectionId)
Close a connection with the specified connection id.
|
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.
|
String |
getApplicationContextId()
Returns the
ApplicationContext.getId() if the
ApplicationContext is available. |
ApplicationEventPublisher |
getApplicationEventPublisher() |
String |
getComponentName()
Will return the name of this component identified by
IntegrationObjectSupport.componentName field. |
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
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. |
ConversionService |
getConversionService() |
Deserializer<?> |
getDeserializer() |
Expression |
getExpression()
Return the primary SpEL expression if this component is expression-based.
|
String |
getHost() |
TcpListener |
getListener() |
TcpMessageMapper |
getMapper() |
List<String> |
getOpenConnectionIds()
Returns a list of (currently) open
TcpConnection connection ids; allows,
for example, broadcast operations to all open connections. |
int |
getPort() |
TcpSender |
getSender() |
List<TcpSender> |
getSenders()
Return the list of senders.
|
Serializer<?> |
getSerializer() |
int |
getSoLinger() |
int |
getSoReceiveBufferSize() |
int |
getSoSendBufferSize() |
int |
getSoTimeout() |
int |
getSoTrafficClass() |
boolean |
isLookupHost() |
boolean |
isRunning() |
boolean |
isSoKeepAlive() |
boolean |
isSoTcpNoDelay() |
void |
registerListener(TcpListener listener)
Registers a TcpListener to receive messages after
the payload has been converted from the input data.
|
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 |
releaseConnection() |
void |
setApplicationContext(ApplicationContext applicationContext) |
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setBeanFactory(BeanFactory beanFactory) |
void |
setChannelResolver(DestinationResolver<MessageChannel> channelResolver)
Specify the
DestinationResolver strategy to use. |
void |
setComponentName(String componentName)
Sets the name of this component.
|
void |
setDeserializer(Deserializer<?> deserializer) |
void |
setHost(String host)
Set the host; requires the factory to be stopped.
|
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 |
setMessageBuilderFactory(MessageBuilderFactory messageBuilderFactory) |
void |
setNioHarvestInterval(int nioHarvestInterval)
How often we clean up closed NIO connections if soTimeout is 0.
|
void |
setPort(int port)
Set the port; requires the factory to be stopped.
|
void |
setReadDelay(long readDelay)
The delay (in milliseconds) before retrying a read after the previous attempt
failed due to insufficient threads.
|
void |
setSerializer(Serializer<?> serializer) |
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 |
setSslHandshakeTimeout(int sslHandshakeTimeout)
Set the handshake timeout used when waiting for SSL handshake data; only applies
to SSL connections, when using NIO.
|
void |
setTaskExecutor(Executor taskExecutor) |
void |
setTcpSocketSupport(TcpSocketSupport tcpSocketSupport) |
void |
start() |
void |
stop()
Stops the server.
|
String |
toString() |
buildNewConnection, getConnectionTest, getConnectTimeout, getTheConnection, initializeConnection, obtainConnection, obtainNewConnection, obtainSharedConnection, setConnectionTest, setConnectTimeout, setTheConnection
addConnection, checkActive, delayRead, doAccept, getDelayedReads, getLifecycleMonitor, getReadDelay, getSslHandshakeTimeout, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, isSingleUse, onInit, processNioSelections, setActive, setLeaveOpen, setSingleUse, setSocketAttributes, unregisterSender, wrapConnection
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setBeanName, setConversionService, setPrimaryExpression, setTaskScheduler
public ThreadAffinityClientConnectionFactory(AbstractClientConnectionFactory connectionFactory)
public TcpConnectionSupport getConnection() throws InterruptedException
AbstractClientConnectionFactory
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.getConnection
in interface ConnectionFactory
getConnection
in class AbstractClientConnectionFactory
InterruptedException
- if interrupted.public void releaseConnection()
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 String getComponentName()
IntegrationObjectSupport
IntegrationObjectSupport.componentName
field.
If IntegrationObjectSupport.componentName
was not set this method will default to the 'beanName' of this component;getComponentName
in interface NamedComponent
getComponentName
in class IntegrationObjectSupport
public void setComponentName(String componentName)
IntegrationObjectSupport
setComponentName
in class IntegrationObjectSupport
componentName
- The component name.public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface ApplicationEventPublisherAware
setApplicationEventPublisher
in class AbstractConnectionFactory
public String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class IntegrationObjectSupport
public void setBeanFactory(BeanFactory beanFactory)
setBeanFactory
in interface BeanFactoryAware
setBeanFactory
in class IntegrationObjectSupport
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
setApplicationContext
in class IntegrationObjectSupport
BeansException
@Nullable public ApplicationEventPublisher getApplicationEventPublisher()
getApplicationEventPublisher
in class AbstractConnectionFactory
public void setChannelResolver(DestinationResolver<MessageChannel> channelResolver)
IntegrationObjectSupport
DestinationResolver
strategy to use.
The default is a BeanFactoryChannelResolver.setChannelResolver
in class IntegrationObjectSupport
channelResolver
- The channel resolver.public Expression getExpression()
ExpressionCapable
getExpression
in interface ExpressionCapable
getExpression
in class IntegrationObjectSupport
public void forceClose(TcpConnection connection)
AbstractClientConnectionFactory
forceClose
in class AbstractClientConnectionFactory
connection
- The connection.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 ConversionService getConversionService()
getConversionService
in class IntegrationObjectSupport
public int getSoTrafficClass()
getSoTrafficClass
in class AbstractConnectionFactory
public void setSoTrafficClass(int soTrafficClass)
setSoTrafficClass
in class AbstractConnectionFactory
soTrafficClass
- the soTrafficClass to setpublic void setHost(String host)
AbstractConnectionFactory
setHost
in class AbstractConnectionFactory
host
- the host.public String getHost()
getHost
in class AbstractConnectionFactory
public void setPort(int port)
AbstractConnectionFactory
setPort
in class AbstractConnectionFactory
port
- the port.public String getApplicationContextId()
IntegrationObjectSupport
ApplicationContext.getId()
if the
ApplicationContext
is available.getApplicationContextId
in class IntegrationObjectSupport
public int getPort()
getPort
in class AbstractConnectionFactory
public TcpListener getListener()
getListener
in class AbstractConnectionFactory
public TcpSender getSender()
getSender
in class AbstractConnectionFactory
public List<TcpSender> getSenders()
AbstractConnectionFactory
getSenders
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)
AbstractConnectionFactory
registerListener
in class AbstractConnectionFactory
listener
- the TcpListener.public void setMessageBuilderFactory(MessageBuilderFactory messageBuilderFactory)
setMessageBuilderFactory
in class IntegrationObjectSupport
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 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 setNioHarvestInterval(int nioHarvestInterval)
AbstractConnectionFactory
soTimeout > 0
because the clean up
process is run as part of the timeout handling.
Default 2000 milliseconds.setNioHarvestInterval
in class AbstractConnectionFactory
nioHarvestInterval
- The interval in milliseconds.public void setSslHandshakeTimeout(int sslHandshakeTimeout)
AbstractConnectionFactory
setSslHandshakeTimeout
in class AbstractConnectionFactory
sslHandshakeTimeout
- the timeout.public void setReadDelay(long readDelay)
AbstractConnectionFactory
setReadDelay
in class AbstractConnectionFactory
readDelay
- the readDelay to set.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 boolean isRunning()
isRunning
in interface Lifecycle
isRunning
in interface ManageableLifecycle
isRunning
in class AbstractConnectionFactory
public void setTcpSocketSupport(TcpSocketSupport tcpSocketSupport)
setTcpSocketSupport
in class AbstractConnectionFactory
public List<String> getOpenConnectionIds()
AbstractConnectionFactory
TcpConnection
connection ids; allows,
for example, broadcast operations to all open connections.getOpenConnectionIds
in class AbstractConnectionFactory
public boolean closeConnection(String connectionId)
AbstractConnectionFactory
closeConnection
in class AbstractConnectionFactory
connectionId
- the connection id.public String toString()
toString
in class AbstractConnectionFactory