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<org.springframework.messaging.Message<?>>,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.core.Ordered,org.springframework.integration.context.ExpressionCapable,org.springframework.integration.context.Orderable,org.springframework.integration.IntegrationPattern,ClientModeCapable,TcpSender,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.IntegrationManagement,org.springframework.integration.support.management.ManageableLifecycle,org.springframework.integration.support.management.TrackableComponent,org.springframework.messaging.MessageHandler,reactor.core.CoreSubscriber<org.springframework.messaging.Message<?>>
public class TcpSendingMessageHandler
extends org.springframework.integration.handler.AbstractMessageHandler
implements TcpSender, org.springframework.integration.support.management.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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longA default retry interval for theClientModeConnectionManagerrescheduling.protected final ObjectFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNewConnection(TcpConnection connection) When we are using sockets owned by aTcpListener, this method is called each time a new connection is made.protected TcpConnectiondoWrite(org.springframework.messaging.Message<?> message) Method that actually does the write.protected ConnectionFactoryprotected Map<String,TcpConnection> longprotected ConnectionFactoryvoidhandleMessageInternal(org.springframework.messaging.Message<?> message) Writes the message payload to the underlying socket, using the specified message format.booleanbooleanbooleanprotected TcpConnectionobtainConnection(org.springframework.messaging.Message<?> message) protected voidonInit()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.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscriber
currentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Field Details
-
DEFAULT_RETRY_INTERVAL
public static final long DEFAULT_RETRY_INTERVALA default retry interval for theClientModeConnectionManagerrescheduling.- See Also:
-
lifecycleMonitor
-
-
Constructor Details
-
TcpSendingMessageHandler
public TcpSendingMessageHandler()
-
-
Method Details
-
obtainConnection
-
handleMessageInternal
public void handleMessageInternal(org.springframework.messaging.Message<?> message) Writes the message payload to the underlying socket, using the specified message format.- Specified by:
handleMessageInternalin classorg.springframework.integration.handler.AbstractMessageHandler- See Also:
-
MessageHandler.handleMessage(org.springframework.messaging.Message)
-
doWrite
Method that actually does the write.- Parameters:
message- The message to write.- Returns:
- the connection.
-
setConnectionFactory
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.- Parameters:
connectionFactory- the connectionFactory to set
-
addNewConnection
Description 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 interfaceTcpSender- Parameters:
connection- The connection.
-
removeDeadConnection
Description copied from interface:TcpSenderWhen we are using sockets owned by aTcpListener, this method is called each time a connection is closed.- Specified by:
removeDeadConnectionin interfaceTcpSender- Parameters:
connection- The connection.
-
getComponentType
- Specified by:
getComponentTypein interfaceorg.springframework.integration.support.context.NamedComponent- Overrides:
getComponentTypein classorg.springframework.integration.handler.MessageHandlerSupport
-
onInit
protected void onInit()- Overrides:
onInitin classorg.springframework.integration.context.IntegrationObjectSupport
-
start
public void start()- Specified by:
startin interfaceorg.springframework.context.Lifecycle- Specified by:
startin interfaceorg.springframework.integration.support.management.ManageableLifecycle
-
stop
public void stop()- Specified by:
stopin interfaceorg.springframework.context.Lifecycle- Specified by:
stopin interfaceorg.springframework.integration.support.management.ManageableLifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle- Specified by:
isRunningin interfaceorg.springframework.integration.support.management.ManageableLifecycle
-
getClientConnectionFactory
- Returns:
- the clientConnectionFactory
-
getServerConnectionFactory
- Returns:
- the serverConnectionFactory
-
getConnections
- Returns:
- the connections
-
isClientMode
public boolean isClientMode()- Specified by:
isClientModein interfaceClientModeCapable- Returns:
- the isClientMode
-
setClientMode
public void setClientMode(boolean isClientMode) - Parameters:
isClientMode- the isClientMode to set
-
getRetryInterval
public long getRetryInterval()- Returns:
- the retryInterval
-
setRetryInterval
public void setRetryInterval(long retryInterval) - Parameters:
retryInterval- the retryInterval to set
-
isClientModeConnected
public boolean isClientModeConnected()- Specified by:
isClientModeConnectedin interfaceClientModeCapable- Returns:
- true if the endpoint is running in client mode.
-
retryConnection
public void retryConnection()Description copied from interface:ClientModeCapableImmediately attempt to establish the connection.- Specified by:
retryConnectionin interfaceClientModeCapable
-