Class TcpInboundGateway
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.ip.tcp.TcpInboundGateway
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Lifecycle,- Phased,- SmartLifecycle,- ExpressionCapable,- OrderlyShutdownCapable,- IntegrationPattern,- ClientModeCapable,- TcpListener,- TcpSender,- NamedComponent,- IntegrationInboundManagement,- IntegrationManagement,- ManageableLifecycle,- ManageableSmartLifecycle,- TrackableComponent
public class TcpInboundGateway
extends MessagingGatewaySupport
implements TcpListener, TcpSender, ClientModeCapable, OrderlyShutdownCapable
Inbound Gateway using a server connection factory - threading is controlled by the
 factory. For java.net connections, each socket can process only one message at a time.
 For java.nio connections, messages may be multiplexed but the client will need to
 provide correlation logic. If the client is a 
TcpOutboundGateway multiplexing
 is not used, but multiple concurrent connections can be used if the connection factory uses
 single-use connections. For true asynchronous bi-directional communication, a pair of
 inbound / outbound channel adapters should be used.- Since:
- 2.0
- Author:
- Gary Russell, Artem Bilan
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupportMessagingGatewaySupport.ConvertingMessagingTemplateNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final longA default retry interval in milliseconds - 60000L.Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupportmessagingTemplateFields inherited from class org.springframework.integration.endpoint.AbstractEndpointlifecycleCondition, lifecycleLockFields 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.context.SmartLifecycleDEFAULT_PHASE
- 
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.intCalled after normal shutdown of schedulers, executors etc, and after the shutdown delay has elapsed, but before any forced shutdown of any remaining active scheduler/executor threads.Can optionally return the number of active messages still in process.intCalled before shutdown begins.protected voiddoStart()Subclasses must implement this method with the start behavior.protected voiddoStop()Subclasses must implement this method with the stop behavior.Subclasses may implement this method to provide component type information.longbooleanbooleanbooleanprotected voidonInit()Subclasses may implement this for initialization logic.booleanCalled by a TCPConnection when a new message arrives.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) voidsetRetryInterval(long retryInterval) Configure a retry interval.Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupportbuildErrorMessage, buildSendTimer, destroy, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, isObserved, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerObservationRegistry, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, setObservationConvention, setReceiverObservationConvention, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrackMethods inherited from class org.springframework.integration.endpoint.AbstractEndpointdoStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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 in milliseconds - 60000L.- See Also:
 
 
- 
- 
Constructor Details- 
TcpInboundGatewaypublic TcpInboundGateway()
 
- 
- 
Method Details- 
onMessageDescription copied from interface:TcpListenerCalled by a TCPConnection when a new message arrives.- Specified by:
- onMessagein interface- TcpListener
- Parameters:
- message- The message.
- Returns:
- true if the message was intercepted
 
- 
isListeningpublic boolean isListening()- Returns:
- true if the associated connection factory is listening.
 
- 
setConnectionFactory- Parameters:
- connectionFactory- the Connection Factory
 
- 
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- MessagingGatewaySupport
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- MessagingGatewaySupport
 
- 
doStartprotected void doStart()Description copied from class:AbstractEndpointSubclasses must implement this method with the start behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Overrides:
- doStartin class- MessagingGatewaySupport
 
- 
doStopprotected void doStop()Description copied from class:AbstractEndpointSubclasses must implement this method with the stop behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Overrides:
- doStopin class- MessagingGatewaySupport
 
- 
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) Configure a retry interval. Defaults toDEFAULT_RETRY_INTERVAL.- 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
 
- 
beforeShutdownpublic int beforeShutdown()Description copied from interface:OrderlyShutdownCapableCalled before shutdown begins. Implementations should stop accepting new messages. Can optionally return the number of active messages in process.- Specified by:
- beforeShutdownin interface- OrderlyShutdownCapable
- Returns:
- The number of active messages if available.
 
- 
afterShutdownpublic int afterShutdown()Description copied from interface:OrderlyShutdownCapableCalled after normal shutdown of schedulers, executors etc, and after the shutdown delay has elapsed, but before any forced shutdown of any remaining active scheduler/executor threads.Can optionally return the number of active messages still in process.- Specified by:
- afterShutdownin interface- OrderlyShutdownCapable
- Returns:
- The number of active messages if available.
 
 
-