Spring Integration

org.springframework.integration.ip.tcp
Class SimpleTcpNetOutboundGateway

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.SimpleTcpNetOutboundGateway
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, Ordered, MessageHandler, MessageProducer, NamedComponent

public class SimpleTcpNetOutboundGateway
extends AbstractReplyProducingMessageHandler

Simple TCP outbound gateway; delegates write to a TcpNetSendingMessageHandler then blocks on read of same socket. Uses Socket and the client thread is dedicated to a request/response pair. No multiplexing of requests over the outbound socket are supported. This class is thread safe in that if multiple clients attempt to send a message, they will be blocked until any existing request/response is processed.

Since:
2.0
Author:
Gary Russell

Field Summary
protected  boolean close
           
protected  Class<NetSocketReader> customSocketReaderClass
           
protected  TcpNetSendingMessageHandler handler
           
protected  int maxMessageSize
           
protected  int messageFormat
           
protected  NetSocketReader reader
           
protected  int soReceiveBufferSize
           
 
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
SimpleTcpNetOutboundGateway(String host, int port)
          Constructs a SimpleTcpNetOutboundGateway that sends data to the specified host and port, and waits for a response.
 
Method Summary
 boolean equals(Object obj)
           
 int getPort()
           
protected  Object handleRequestMessage(Message<?> requestMessage)
          Synchronized to prevent multiplexing requests over the same socket.
 int hashCode()
           
 void setClose(boolean close)
           
 void setCustomSocketReaderClassName(String customSocketReaderClassName)
           
 void setCustomSocketWriterClassName(String customSocketWriterClassName)
           
 void setMessageFormat(int messageFormat)
           
 void setReplyChannel(MessageChannel replyChannel)
          Specify the Spring Integration reply channel.
 void setSoKeepAlive(boolean soKeepAlive)
           
 void setSoLinger(int soLinger)
           
 void setSoReceiveBufferSize(int size)
           
 void setSoSendBufferSize(int size)
           
 void setSoTcpNoDelay(boolean soTcpNoDelay)
           
 void setSoTimeout(int timeout)
           
 void setSoTrafficClass(int soTrafficClass)
           
 
Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
getOutputChannel, handleMessageInternal, handleResult, sendReplyMessage, setChannelResolver, setOutputChannel, setRequiresReply, setSendTimeout
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
getComponentType, getOrder, handleMessage, resolveReplyChannel, setOrder
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString, writeMessageHistory
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

handler

protected TcpNetSendingMessageHandler handler

customSocketReaderClass

protected Class<NetSocketReader> customSocketReaderClass

messageFormat

protected int messageFormat

maxMessageSize

protected int maxMessageSize

soReceiveBufferSize

protected int soReceiveBufferSize

reader

protected NetSocketReader reader

close

protected boolean close
Constructor Detail

SimpleTcpNetOutboundGateway

public SimpleTcpNetOutboundGateway(String host,
                                   int port)
Constructs a SimpleTcpNetOutboundGateway that sends data to the specified host and port, and waits for a response.

Parameters:
host - The host.
port - The port.
Method Detail

handleRequestMessage

protected Object handleRequestMessage(Message<?> requestMessage)
Synchronized to prevent multiplexing requests over the same socket.

Specified by:
handleRequestMessage in class AbstractReplyProducingMessageHandler

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
Returns:
whether the MessageHandler delegate for this Gateway is equal to the provided object
See Also:
Object.equals(Object)

getPort

public int getPort()
Returns:
the port number of the MessageHandler delegate for this Gateway
See Also:
AbstractInternetProtocolSendingMessageHandler.getPort()

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
hashcode value of the MessageHandler delegate for this Gateway
See Also:
Object.hashCode()

setCustomSocketWriterClassName

public void setCustomSocketWriterClassName(String customSocketWriterClassName)
                                    throws ClassNotFoundException
Parameters:
customSocketWriterClassName -
Throws:
ClassNotFoundException
See Also:
TcpNetSendingMessageHandler.setCustomSocketWriterClassName(java.lang.String)

setMessageFormat

public void setMessageFormat(int messageFormat)
Parameters:
messageFormat -
See Also:
AbstractTcpSendingMessageHandler.setMessageFormat(int)

setSoKeepAlive

public void setSoKeepAlive(boolean soKeepAlive)
Parameters:
soKeepAlive -
See Also:
AbstractTcpSendingMessageHandler.setSoKeepAlive(boolean)

setSoLinger

public void setSoLinger(int soLinger)
Parameters:
soLinger -
See Also:
AbstractTcpSendingMessageHandler.setSoLinger(int)

setSoReceiveBufferSize

public void setSoReceiveBufferSize(int size)
Parameters:
size -
See Also:
AbstractInternetProtocolSendingMessageHandler.setSoReceiveBufferSize(int)

setSoSendBufferSize

public void setSoSendBufferSize(int size)
Parameters:
size -
See Also:
AbstractInternetProtocolSendingMessageHandler.setSoSendBufferSize(int)

setSoTcpNoDelay

public void setSoTcpNoDelay(boolean soTcpNoDelay)
Parameters:
soTcpNoDelay -
See Also:
AbstractTcpSendingMessageHandler.setSoTcpNoDelay(boolean)

setSoTimeout

public void setSoTimeout(int timeout)
Parameters:
timeout -
See Also:
AbstractInternetProtocolSendingMessageHandler.setSoTimeout(int)

setSoTrafficClass

public void setSoTrafficClass(int soTrafficClass)
Parameters:
soTrafficClass -
See Also:
AbstractTcpSendingMessageHandler.setSoTrafficClass(int)

setCustomSocketReaderClassName

public void setCustomSocketReaderClassName(String customSocketReaderClassName)
                                    throws ClassNotFoundException
Parameters:
customSocketReaderClassName - the NetSocketReader class to use
Throws:
ClassNotFoundException

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.


setClose

public void setClose(boolean close)
Parameters:
close - the close to set

Spring Integration

Copyright © 2010. All Rights Reserved.