public class FailoverClientConnectionFactory extends AbstractClientConnectionFactory
TcpConnection
s
that can iterate over a connection from each factory until the write
succeeds or the list is exhausted.DEFAULT_REPLY_TIMEOUT, lifecycleMonitor
logger
Constructor and Description |
---|
FailoverClientConnectionFactory(List<AbstractClientConnectionFactory> factories) |
Modifier and Type | Method and Description |
---|---|
boolean |
isRunning()
Returns true if all factories are running
|
protected TcpConnectionSupport |
obtainConnection() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
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 |
start() |
void |
stop()
Stops the server.
|
buildNewConnection, forceClose, getConnection, getTheConnection, initializeConnection, obtainNewConnection, obtainSharedConnection, setTheConnection
addConnection, checkActive, closeConnection, doAccept, getApplicationEventPublisher, getDeserializer, getHost, getListener, getMapper, getOpenConnectionIds, getPhase, getPort, getSender, getSerializer, getSoLinger, getSoReceiveBufferSize, getSoSendBufferSize, getSoTimeout, getSoTrafficClass, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, isAutoStartup, isLookupHost, isSingleUse, isSoKeepAlive, isSoTcpNoDelay, processNioSelections, setActive, setApplicationEventPublisher, setDeserializer, setInterceptorFactoryChain, setLookupHost, setMapper, setNioHarvestInterval, setSerializer, setSingleUse, setSocketAttributes, setSoKeepAlive, setSoLinger, setSoReceiveBufferSize, setSoSendBufferSize, setSoTcpNoDelay, setSoTimeout, setSoTrafficClass, setTaskExecutor, setTcpSocketSupport, stop, wrapConnection
afterPropertiesSet, getApplicationContextId, getBeanFactory, getComponentName, getComponentType, getConversionService, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, setMessageBuilderFactory, setTaskScheduler, toString
public FailoverClientConnectionFactory(List<AbstractClientConnectionFactory> factories)
protected void onInit() throws Exception
IntegrationObjectSupport
onInit
in class AbstractConnectionFactory
Exception
- Any exception.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 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.
registerListener
in class AbstractConnectionFactory
listener
- the TcpListener.public void registerSender(TcpSender sender)
AbstractConnectionFactory
registerSender
in class AbstractConnectionFactory
sender
- The senderprotected TcpConnectionSupport obtainConnection() throws Exception
obtainConnection
in class AbstractClientConnectionFactory
Exception
public void start()
start
in interface Lifecycle
start
in class AbstractConnectionFactory
public void stop()
AbstractConnectionFactory
stop
in interface Lifecycle
stop
in class AbstractConnectionFactory
public boolean isRunning()
isRunning
in interface Lifecycle
isRunning
in class AbstractConnectionFactory