Class FailoverClientConnectionFactory
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.FailoverClientConnectionFactory
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- InitializingBean,- ApplicationContextAware,- ApplicationEventPublisherAware,- Lifecycle,- ExpressionCapable,- ConnectionFactory,- NamedComponent,- ManageableLifecycle
Given a list of connection factories, serves up 
TcpConnections
 that can iterate over a connection from each factory until the write
 succeeds or the list is exhausted.- Since:
- 2.2
- Author:
- Gary Russell
- 
Field SummaryFields inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactoryDEFAULT_REPLY_TIMEOUT, lifecycleMonitorFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, logger
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct an instance with the provided delegate factories.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanReturn true if all factories are running.protected TcpConnectionSupportprotected voidonInit()Subclasses may implement this for initialization logic.voidregisterListener(TcpListener listener) Delegate TCP Client Connection factories that are used to receive data need a Listener to send the messages to.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.voidsetCloseOnRefresh(boolean closeOnRefresh) When using a shared connectionsingleUseis false, set this to true to close the old shared connection after a refresh.voidsetRefreshSharedInterval(long refreshSharedInterval) When using a shared connectionsingleUseis false, specify how long to wait before trying to fail back to start from the beginning of the factory list.voidstart()voidstop()Stops the server.Methods inherited from class org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactorybuildNewConnection, enableManualListenerRegistration, forceClose, getConnection, getConnectionTest, getConnectTimeout, getTheConnection, initializeConnection, obtainNewConnection, obtainSharedConnection, setConnectionTest, setConnectTimeout, setTheConnectionMethods inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactoryaddConnection, 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, isSingleUse, isSoKeepAlive, isSoTcpNoDelay, processNioSelections, setActive, setApplicationEventPublisher, setDeserializer, setHost, setInterceptorFactoryChain, setLeaveOpen, setLookupHost, setMapper, setNioHarvestInterval, setPort, setReadDelay, setSerializer, setSingleUse, setSocketAttributes, setSoKeepAlive, setSoLinger, setSoReceiveBufferSize, setSoSendBufferSize, setSoTcpNoDelay, setSoTimeout, setSoTrafficClass, setSslHandshakeTimeout, setTaskExecutor, setTcpSocketSupport, toString, unregisterSender, wrapConnectionMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, 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
- 
Constructor Details- 
FailoverClientConnectionFactoryConstruct an instance with the provided delegate factories.- Parameters:
- factories- the delegates.
 
 
- 
- 
Method Details
- 
setCloseOnRefreshpublic void setCloseOnRefresh(boolean closeOnRefresh) When using a shared connectionsingleUseis false, set this to true to close the old shared connection after a refresh. If this is false, the connection will remain open, but unused until its connection factory is again used to get a connection. Default is false for backwards compatibility. Cannot be changed when usingCachingClientConnectionFactorydelegates.- Parameters:
- closeOnRefresh- true to close.
- Since:
- 4.3.22
- See Also:
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- AbstractConnectionFactory
 
- 
registerListenerDelegate TCP Client Connection factories that are used to receive data need a Listener to send the messages to. This applies to client factories used for outbound gateways or for a pair of collaborating channel adapters.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 FailoverTcpConnections, 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. - Overrides:
- registerListenerin class- AbstractConnectionFactory
- Parameters:
- listener- the TcpListener.
 
- 
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
 
- 
obtainConnection- Overrides:
- obtainConnectionin class- AbstractClientConnectionFactory
- Throws:
- InterruptedException
 
- 
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()Return true if all factories are running.- Specified by:
- isRunningin interface- Lifecycle
- Specified by:
- isRunningin interface- ManageableLifecycle
- Overrides:
- isRunningin class- AbstractConnectionFactory