Class TcpSendingMessageHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.ip.tcp.TcpSendingMessageHandler
- All Implemented Interfaces:
- org.reactivestreams.Subscriber<Message<?>>,- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Lifecycle,- Ordered,- ComponentSourceAware,- ExpressionCapable,- Orderable,- IntegrationPattern,- ClientModeCapable,- TcpSender,- NamedComponent,- IntegrationManagement,- ManageableLifecycle,- TrackableComponent,- MessageHandler,- reactor.core.CoreSubscriber<Message<?>>
public class TcpSendingMessageHandler
extends AbstractMessageHandler
implements TcpSender, ManageableLifecycle, ClientModeCapable
Tcp outbound channel adapter using a TcpConnection to
 send data - if the connection factory is a server
 factory, the TcpListener owns the connections. If it is
 a client factory, this object owns the connection.
- Since:
- 2.0
- Author:
- Gary Russell, Artem Bilan, Christian Tzolov
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final longA default retry interval for theClientModeConnectionManagerrescheduling.protected final LockFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddNewConnection(TcpConnection connection) When we are using sockets owned by aTcpListener, this method is called each time a new connection is made.protected TcpConnectionMethod that actually does the write.protected ConnectionFactorySubclasses may implement this method to provide component type information.protected Map<String,TcpConnection> longprotected ConnectionFactoryvoidhandleMessageInternal(Message<?> message) Writes the message payload to the underlying socket, using the specified message format.booleanbooleanbooleanprotected TcpConnectionobtainConnection(Message<?> message) protected voidonInit()Subclasses may implement this for initialization logic.voidremoveDeadConnection(TcpConnection connection) When we are using sockets owned by aTcpListener, this method is called each time a connection is closed.voidImmediately attempt to establish the connection.voidsetClientMode(boolean isClientMode) voidsetConnectionFactory(AbstractConnectionFactory connectionFactory) Sets the client or server connection factory; for this (an outbound adapter), if the factory is a server connection factory, the sockets are owned by a receiving channel adapter and this adapter is used to send replies.voidsetRetryInterval(long retryInterval) voidstart()voidstop()Methods inherited from class org.springframework.integration.handler.AbstractMessageHandlerhandleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, destroy, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscribercurrentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Field Details- 
DEFAULT_RETRY_INTERVALpublic static final long DEFAULT_RETRY_INTERVALA default retry interval for theClientModeConnectionManagerrescheduling.- See Also:
 
- 
lifecycleMonitor
 
- 
- 
Constructor Details- 
TcpSendingMessageHandlerpublic TcpSendingMessageHandler()
 
- 
- 
Method Details- 
obtainConnection
- 
handleMessageInternalWrites the message payload to the underlying socket, using the specified message format.- Specified by:
- handleMessageInternalin class- AbstractMessageHandler
- See Also:
 
- 
doWriteMethod that actually does the write.- Parameters:
- message- The message to write.
- Returns:
- the connection.
 
- 
setConnectionFactorySets the client or server connection factory; for this (an outbound adapter), if the factory is a server connection factory, the sockets are owned by a receiving channel adapter and this adapter is used to send replies.- Parameters:
- connectionFactory- the connectionFactory to set
 
- 
addNewConnectionDescription copied from interface:TcpSenderWhen we are using sockets owned by aTcpListener, this method is called each time a new connection is made.- Specified by:
- addNewConnectionin interface- TcpSender
- Parameters:
- connection- The connection.
 
- 
removeDeadConnectionDescription copied from interface:TcpSenderWhen we are using sockets owned by aTcpListener, this method is called each time a connection is closed.- Specified by:
- removeDeadConnectionin interface- TcpSender
- Parameters:
- connection- The connection.
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- MessageHandlerSupport
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- IntegrationObjectSupport
 
- 
startpublic void start()- Specified by:
- startin interface- Lifecycle
- Specified by:
- startin interface- ManageableLifecycle
 
- 
stoppublic void stop()- Specified by:
- stopin interface- Lifecycle
- Specified by:
- stopin interface- ManageableLifecycle
 
- 
isRunningpublic boolean isRunning()- Specified by:
- isRunningin interface- Lifecycle
- Specified by:
- isRunningin interface- ManageableLifecycle
 
- 
getClientConnectionFactory- Returns:
- the clientConnectionFactory
 
- 
getServerConnectionFactory- Returns:
- the serverConnectionFactory
 
- 
getConnections- Returns:
- the connections
 
- 
isClientModepublic boolean isClientMode()- Specified by:
- isClientModein interface- ClientModeCapable
- Returns:
- the isClientMode
 
- 
setClientModepublic void setClientMode(boolean isClientMode) - Parameters:
- isClientMode- the isClientMode to set
 
- 
getRetryIntervalpublic long getRetryInterval()- Returns:
- the retryInterval
 
- 
setRetryIntervalpublic void setRetryInterval(long retryInterval) - Parameters:
- retryInterval- the retryInterval to set
 
- 
isClientModeConnectedpublic boolean isClientModeConnected()- Specified by:
- isClientModeConnectedin interface- ClientModeCapable
- Returns:
- true if the endpoint is running in client mode.
 
- 
retryConnectionpublic void retryConnection()Description copied from interface:ClientModeCapableImmediately attempt to establish the connection.- Specified by:
- retryConnectionin interface- ClientModeCapable
 
 
-