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:
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.context.Phased
,org.springframework.context.SmartLifecycle
,org.springframework.integration.context.ExpressionCapable
,org.springframework.integration.context.OrderlyShutdownCapable
,org.springframework.integration.IntegrationPattern
,ClientModeCapable
,TcpListener
,TcpSender
,org.springframework.integration.support.context.NamedComponent
,org.springframework.integration.support.management.IntegrationInboundManagement
,org.springframework.integration.support.management.IntegrationManagement
,org.springframework.integration.support.management.ManageableLifecycle
,org.springframework.integration.support.management.ManageableSmartLifecycle
,org.springframework.integration.support.management.TrackableComponent
public class TcpInboundGateway
extends org.springframework.integration.gateway.MessagingGatewaySupport
implements TcpListener, TcpSender, ClientModeCapable, org.springframework.integration.context.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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.gateway.MessagingGatewaySupport.ConvertingMessagingTemplate
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 long
A default retry interval in milliseconds - 60000L.Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplate
Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLock
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNewConnection
(TcpConnection connection) When we are using sockets owned by aTcpListener
, this method is called each time a new connection is made.int
int
protected void
doStart()
protected void
doStop()
long
boolean
boolean
boolean
protected void
onInit()
boolean
onMessage
(org.springframework.messaging.Message<?> message) Called by a TCPConnection when a new message arrives.void
removeDeadConnection
(TcpConnection connection) When we are using sockets owned by aTcpListener
, this method is called each time a connection is closed.void
Immediately attempt to establish the connection.void
setClientMode
(boolean isClientMode) void
setConnectionFactory
(AbstractConnectionFactory connectionFactory) void
setRetryInterval
(long retryInterval) Configure a retry interval.Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, 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, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrack
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
Methods 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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods 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 in milliseconds - 60000L.- See Also:
-
-
Constructor Details
-
TcpInboundGateway
public TcpInboundGateway()
-
-
Method Details
-
onMessage
public boolean onMessage(org.springframework.messaging.Message<?> message) Description copied from interface:TcpListener
Called by a TCPConnection when a new message arrives.- Specified by:
onMessage
in interfaceTcpListener
- Parameters:
message
- The message.- Returns:
- true if the message was intercepted
-
isListening
public boolean isListening()- Returns:
- true if the associated connection factory is listening.
-
setConnectionFactory
- Parameters:
connectionFactory
- the Connection Factory
-
addNewConnection
Description copied from interface:TcpSender
When we are using sockets owned by aTcpListener
, this method is called each time a new connection is made.- Specified by:
addNewConnection
in interfaceTcpSender
- Parameters:
connection
- The connection.
-
removeDeadConnection
Description copied from interface:TcpSender
When we are using sockets owned by aTcpListener
, this method is called each time a connection is closed.- Specified by:
removeDeadConnection
in interfaceTcpSender
- Parameters:
connection
- The connection.
-
getComponentType
- Specified by:
getComponentType
in interfaceorg.springframework.integration.support.context.NamedComponent
- Overrides:
getComponentType
in classorg.springframework.integration.gateway.MessagingGatewaySupport
-
onInit
protected void onInit()- Overrides:
onInit
in classorg.springframework.integration.gateway.MessagingGatewaySupport
-
doStart
protected void doStart()- Overrides:
doStart
in classorg.springframework.integration.gateway.MessagingGatewaySupport
-
doStop
protected void doStop()- Overrides:
doStop
in classorg.springframework.integration.gateway.MessagingGatewaySupport
-
isClientMode
public boolean isClientMode()- Specified by:
isClientMode
in 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) Configure a retry interval. Defaults toDEFAULT_RETRY_INTERVAL
.- Parameters:
retryInterval
- the retryInterval to set
-
isClientModeConnected
public boolean isClientModeConnected()- Specified by:
isClientModeConnected
in interfaceClientModeCapable
- Returns:
- true if the endpoint is running in client mode.
-
retryConnection
public void retryConnection()Description copied from interface:ClientModeCapable
Immediately attempt to establish the connection.- Specified by:
retryConnection
in interfaceClientModeCapable
-
beforeShutdown
public int beforeShutdown()- Specified by:
beforeShutdown
in interfaceorg.springframework.integration.context.OrderlyShutdownCapable
-
afterShutdown
public int afterShutdown()- Specified by:
afterShutdown
in interfaceorg.springframework.integration.context.OrderlyShutdownCapable
-