Spring Integration

org.springframework.integration.ip.tcp
Class TcpOutboundGateway

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.handler.AbstractMessageHandler
          extended by org.springframework.integration.handler.AbstractReplyProducingMessageHandler
              extended by org.springframework.integration.ip.tcp.TcpOutboundGateway
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, Ordered, NamedComponent, 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
Author:
Gary Russell

Field Summary
protected  AbstractConnectionFactory connectionFactory
           
 
Fields inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
DEFAULT_SEND_TIMEOUT
 
Fields inherited from class org.springframework.integration.handler.AbstractMessageHandler
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
TcpOutboundGateway()
           
 
Method Summary
 void addNewConnection(TcpConnection connection)
          When we are using sockets owned by a TcpListener, this method is called each time a new connection is made.
protected  Object handleRequestMessage(Message<?> requestMessage)
          Subclasses must implement this method to handle the request Message.
 boolean isListening()
           
 boolean onMessage(Message<?> message)
          Called by a TCPConnection when a new message arrives.
 void removeDeadConnection(TcpConnection connection)
          When we are using sockets owned by a TcpListener, this method is called each time a connection is closed.
 void setConnectionFactory(AbstractConnectionFactory connectionFactory)
           
 void setReplyChannel(MessageChannel replyChannel)
          Specify the Spring Integration reply channel.
 void setReplyTimeout(long timeout)
           
 void setRequestTimeout(long requestTimeout)
           
 
Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
getMessagingTemplate, handleMessageInternal, onInit, setChannelResolver, setOutputChannel, setRequiresReply, setSendTimeout, shouldCopyRequestHeaders
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
getComponentType, getOrder, handleMessage, setOrder, setShouldTrack
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getRequiredMetadataPersister, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, 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.context.NamedComponent
getComponentName
 

Field Detail

connectionFactory

protected AbstractConnectionFactory connectionFactory
Constructor Detail

TcpOutboundGateway

public TcpOutboundGateway()
Method Detail

handleRequestMessage

protected 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.

setReplyTimeout

public void setReplyTimeout(long timeout)
Parameters:
replyTimeout - the replyTimeout to set

setRequestTimeout

public void setRequestTimeout(long requestTimeout)
Parameters:
requestTimeout - the requestTimeout to set

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.


Spring Integration

Copyright © 2010. All Rights Reserved.