org.springframework.integration.ip.udp
Class UnicastReceivingChannelAdapter
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter
org.springframework.integration.ip.udp.UnicastReceivingChannelAdapter
- All Implemented Interfaces:
- java.lang.Runnable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, NamedComponent, MessageProducer, TrackableComponent, CommonSocketOptions
- Direct Known Subclasses:
- MulticastReceivingChannelAdapter
public class UnicastReceivingChannelAdapter
- extends AbstractInternetProtocolReceivingChannelAdapter
A channel adapter to receive incoming UDP packets. Packets can optionally be preceded by a
4 byte length field, used to validate that all data was received. Packets may also contain
information indicating an acknowledgment needs to be sent.
- Since:
- 2.0
- Author:
- Gary Russell
Methods inherited from class org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter |
checkTaskExecutor, doStart, getLocalAddress, getPort, getReceiveBufferSize, getSoReceiveBufferSize, getSoTimeout, getTaskExecutor, isActive, isListening, setListening, setLocalAddress, setPoolSize, setReceiveBufferSize, setSoReceiveBufferSize, setSoTimeout, setTaskExecutor |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
UnicastReceivingChannelAdapter
public UnicastReceivingChannelAdapter(int port)
- Constructs a UnicastReceivingChannelAdapter that listens on the specified port.
- Parameters:
port
-
UnicastReceivingChannelAdapter
public UnicastReceivingChannelAdapter(int port,
boolean lengthCheck)
- Constructs a UnicastReceivingChannelAdapter that listens for packets on
the specified port. Enables setting the lengthCheck option, which expects
a length to precede the incoming packets.
- Parameters:
port
- The port.lengthCheck
- If true, enables the lengthCheck Option.
run
public void run()
sendAck
protected void sendAck(Message<byte[]> message)
asyncSendMessage
protected boolean asyncSendMessage(java.net.DatagramPacket packet)
receive
protected java.net.DatagramPacket receive()
throws java.lang.Exception
- Throws:
java.lang.Exception
setSocket
public void setSocket(java.net.DatagramSocket socket)
- Parameters:
socket
- the socket to set
getTheSocket
protected java.net.DatagramSocket getTheSocket()
getSocket
protected java.net.DatagramSocket getSocket()
setSocketAttributes
protected void setSocketAttributes(java.net.DatagramSocket socket)
throws java.net.SocketException
- Sets timeout and receive buffer size
- Parameters:
socket
-
- Throws:
java.net.SocketException
doStop
protected void doStop()
- Description copied from class:
MessageProducerSupport
- Takes no action by default. Subclasses may override this if they
need lifecycle-managed behavior.
- Overrides:
doStop
in class AbstractInternetProtocolReceivingChannelAdapter
setSoSendBufferSize
public void setSoSendBufferSize(int soSendBufferSize)
- See Also:
Socket.setSendBufferSize(int)
,
DatagramSocket.setSendBufferSize(int)
setLookupHost
public void setLookupHost(boolean lookupHost)
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 IntegrationObjectSupport