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:
- Runnable, BeanFactoryAware, BeanNameAware, InitializingBean, Lifecycle, Phased, 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, isListening, setLocalAddress, setPoolSize, setReceiveBufferSize, setSoReceiveBufferSize, setSoTimeout, setTaskExecutor |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getRequiredMetadataPersister, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, toString |
socket
protected volatile DatagramSocket socket
mapper
protected final DatagramPacketMessageMapper mapper
soSendBufferSize
protected volatile int soSendBufferSize
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(DatagramPacket packet)
receive
protected DatagramPacket receive()
throws Exception
- Throws:
Exception
getSocket
protected DatagramSocket getSocket()
doStop
protected void doStop()
- Description copied from class:
AbstractEndpoint
- Subclasses must implement this method with the stop behavior.
This method will be invoked while holding the
AbstractEndpoint.lifecycleLock
.
- Overrides:
doStop
in class AbstractInternetProtocolReceivingChannelAdapter
setSoSendBufferSize
public void setSoSendBufferSize(int soSendBufferSize)
- Specified by:
setSoSendBufferSize
in interface CommonSocketOptions
- Overrides:
setSoSendBufferSize
in class AbstractInternetProtocolReceivingChannelAdapter
- See Also:
Socket.setSendBufferSize(int)
,
DatagramSocket.setSendBufferSize(int)
Copyright © 2010. All Rights Reserved.