Class TcpOutboundGateway
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
org.springframework.integration.handler.AbstractReplyProducingMessageHandler
org.springframework.integration.ip.tcp.TcpOutboundGateway
- All Implemented Interfaces:
- org.reactivestreams.Subscriber<Message<?>>,- Aware,- BeanClassLoaderAware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Lifecycle,- Ordered,- ExpressionCapable,- Orderable,- MessageProducer,- HeaderPropagationAware,- IntegrationPattern,- TcpListener,- TcpSender,- NamedComponent,- IntegrationManagement,- ManageableLifecycle,- TrackableComponent,- MessageHandler,- reactor.core.CoreSubscriber<Message<?>>
public class TcpOutboundGateway
extends AbstractReplyProducingMessageHandler
implements TcpSender, TcpListener, ManageableLifecycle
TCP outbound gateway that uses a client connection factory. If the factory is configured
 for single-use connections, each request is sent on a new connection; if the factory does not use
 single use connections, each request is blocked until the previous response is received
 (or times out). Asynchronous requests/responses over the same connection are not
 supported - use a pair of outbound/inbound adapters for that use case.
 
 Lifecycle methods delegate to the underlying AbstractConnectionFactory.
- Since:
- 2.0
- Author:
- Gary Russell, Artem Bilan
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerAbstractReplyProducingMessageHandler.RequestHandlerNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandlermessagingTemplateFields 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 voiddoInit()Subclasses may implement this method to provide component type information.protected AbstractConnectionFactoryprotected ObjecthandleRequestMessage(Message<?> requestMessage) Subclasses must implement this method to handle the request Message.booleanbooleanCalled 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.voidsetCloseStreamAfterSend(boolean closeStreamAfterSend) Set to true to close the connection ouput stream after sending without closing the connection.voidsetConnectionFactory(AbstractClientConnectionFactory connectionFactory) voidsetIntegrationEvaluationContext(EvaluationContext evaluationContext) voidsetRemoteTimeout(long remoteTimeout) voidsetRemoteTimeoutExpression(Expression remoteTimeoutExpression) voidsetReplyChannel(MessageChannel replyChannel) Specify the Spring Integration reply channel.voidsetReplyChannelName(String replyChannel) Specify the Spring Integration reply channel name.voidsetRequestTimeout(long requestTimeout) voidsetSecondChanceDelay(int secondChanceDelay) When using NIO and the server closes the socket after sending the reply, an error message representing the close may appear before the reply.voidsetUnsolicitedMessageChannel(MessageChannel unsolicitedMessageChannel) Set the channel for unsolicited incoming messages, or late replies.voidsetUnsolicitedMessageChannelName(String unsolicitedMessageChannelName) Set the channel name for unsolicited incoming messages, or late replies.voidstart()voidstop()Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerdoInvokeAdvisedRequestHandler, getBeanClassLoader, getIntegrationPatternType, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReplyMethods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandleraddNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class org.springframework.integration.handler.AbstractMessageHandlerhandleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, destroy, 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, 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 reactor.core.CoreSubscribercurrentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Constructor Details- 
TcpOutboundGatewaypublic TcpOutboundGateway()
 
- 
- 
Method Details- 
setConnectionFactory
- 
setRequestTimeoutpublic void setRequestTimeout(long requestTimeout) - Parameters:
- requestTimeout- the requestTimeout to set
 
- 
setRemoteTimeoutpublic void setRemoteTimeout(long remoteTimeout) - Parameters:
- remoteTimeout- the remoteTimeout to set
 
- 
setRemoteTimeoutExpression- Parameters:
- remoteTimeoutExpression- the remoteTimeoutExpression to set
 
- 
setIntegrationEvaluationContext
- 
setReplyChannelSpecify the Spring Integration reply channel. If this property is not set the gateway will check for a 'replyChannel' header on the request.- Parameters:
- replyChannel- The reply channel.
 
- 
setReplyChannelNameSpecify the Spring Integration reply channel name. If this property is not set the gateway will check for a 'replyChannel' header on the request.- Parameters:
- replyChannel- The reply channel.
- Since:
- 5.0
 
- 
setUnsolicitedMessageChannelNameSet the channel name for unsolicited incoming messages, or late replies.- Parameters:
- unsolicitedMessageChannelName- the channel name.
- Since:
- 5.4
 
- 
setUnsolicitedMessageChannelSet the channel for unsolicited incoming messages, or late replies.- Parameters:
- unsolicitedMessageChannel- the channel.
- Since:
- 5.4
 
- 
setCloseStreamAfterSendpublic void setCloseStreamAfterSend(boolean closeStreamAfterSend) Set to true to close the connection ouput stream after sending without closing the connection. Use to signal EOF to the server, such as when using aByteArrayRawSerializer. Requires a single-use connection factory.- Parameters:
- closeStreamAfterSend- true to close.
- Since:
- 5.2
 
- 
setSecondChanceDelaypublic void setSecondChanceDelay(int secondChanceDelay) When using NIO and the server closes the socket after sending the reply, an error message representing the close may appear before the reply. Set the delay, in seconds, to wait for an actual reply after anErrorMessageis received. Default 2 seconds.- Parameters:
- secondChanceDelay- the delay.
- Since:
- 5.0.8
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- MessageHandlerSupport
 
- 
doInitprotected void doInit()- Overrides:
- doInitin class- AbstractReplyProducingMessageHandler
 
- 
handleRequestMessageDescription copied from class:AbstractReplyProducingMessageHandlerSubclasses must implement this method to handle the request Message. The return value may be a Message, a MessageBuilder, or any plain Object. The base class will handle the final creation of a reply Message from any of those starting points. If the return value is null, the Message flow will end here.- Specified by:
- handleRequestMessagein class- AbstractReplyProducingMessageHandler
- Parameters:
- requestMessage- The request message.
- Returns:
- The result of handling the message, or null.
 
- 
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
 
- 
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.
 
- 
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
 
- 
getConnectionFactory- Returns:
- the connectionFactory
 
 
-