org.springframework.integration.ip.tcp
Class TcpOutboundGateway
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractReplyProducingMessageHandler
org.springframework.integration.ip.tcp.TcpOutboundGateway
- All Implemented Interfaces:
- BeanFactoryAware, BeanNameAware, InitializingBean, Ordered, NamedComponent, Orderable, MessageHandler, MessageProducer, TrackableComponent, TcpListener, TcpSender
public class TcpOutboundGateway
- extends AbstractReplyProducingMessageHandler
- implements TcpSender, TcpListener
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.
- Since:
- 2.0
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
connectionFactory
protected AbstractConnectionFactory connectionFactory
TcpOutboundGateway
public TcpOutboundGateway()
setRequestTimeout
public void setRequestTimeout(long requestTimeout)
- Parameters:
requestTimeout
- the requestTimeout to set
setReplyTimeout
public void setReplyTimeout(long replyTimeout)
- Parameters:
replyTimeout
- the replyTimeout to set
handleRequestMessage
protected java.lang.Object handleRequestMessage(Message<?> requestMessage)
- Description copied from class:
AbstractReplyProducingMessageHandler
- Subclasses 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:
handleRequestMessage
in class AbstractReplyProducingMessageHandler
onMessage
public boolean onMessage(Message<?> message)
- Description copied from interface:
TcpListener
- Called by a TCPConnection when a new message arrives.
- Specified by:
onMessage
in interface TcpListener
- Parameters:
message
- The message.
- Returns:
- true if the message was intercepted
isListening
public boolean isListening()
setConnectionFactory
public void setConnectionFactory(AbstractConnectionFactory connectionFactory)
addNewConnection
public void addNewConnection(TcpConnection connection)
- Description copied from interface:
TcpSender
- When we are using sockets owned by a
TcpListener
, this
method is called each time a new connection is made.
- Specified by:
addNewConnection
in interface TcpSender
- Parameters:
connection
- The connection.
removeDeadConnection
public void removeDeadConnection(TcpConnection connection)
- Description copied from interface:
TcpSender
- When we are using sockets owned by a
TcpListener
, this
method is called each time a connection is closed.
- Specified by:
removeDeadConnection
in interface TcpSender
- Parameters:
connection
- The connection.
setReplyChannel
public void setReplyChannel(MessageChannel replyChannel)
- Specify the Spring Integration reply channel. If this property is not
set the gateway will check for a 'replyChannel' header on the request.
getComponentType
public java.lang.String getComponentType()
- Description copied from class:
IntegrationObjectSupport
- Subclasses may implement this method to provide component type information.
- Specified by:
getComponentType
in interface NamedComponent
- Overrides:
getComponentType
in class AbstractMessageHandler