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
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,SmartInitializingSingleton
,ApplicationContextAware
,ApplicationEventPublisherAware
,Lifecycle
,Phased
,SmartLifecycle
,ExpressionCapable
,MessageProducer
,IntegrationPattern
,CommonSocketOptions
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
,SchedulingAwareRunnable
- Direct Known Subclasses:
MulticastReceivingChannelAdapter
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, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLock
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionUnicastReceivingChannelAdapter
(int port) Constructs a UnicastReceivingChannelAdapter that listens on the specified port.UnicastReceivingChannelAdapter
(int port, boolean lengthCheck) Constructs a UnicastReceivingChannelAdapter that listens for packets on the specified port. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
asyncSendMessage
(DatagramPacket packet) protected void
doSend
(DatagramPacket packet) protected void
doStop()
Take no action by default.Subclasses may implement this method to provide component type information.int
getPort()
protected DatagramSocket
boolean
protected void
onInit()
Subclasses may implement this for initialization logic.protected DatagramPacket
receive()
void
run()
protected void
void
setLengthCheck
(boolean lengthCheck) void
setLookupHost
(boolean lookupHost) void
setSocket
(DatagramSocket socket) protected void
setSocketAttributes
(DatagramSocket socket) Sets timeout and receive buffer size; calls the socket customizer.void
setSocketCustomizer
(SocketCustomizer socketCustomizer) Set a customizer to further configure the socket after creation.void
setSoSendBufferSize
(int soSendBufferSize) Methods inherited from class org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter
checkTaskExecutor, doStart, getApplicationEventPublisher, getLocalAddress, getReceiveBufferSize, getSoReceiveBufferSize, getSoTimeout, getTaskExecutor, isListening, setApplicationEventPublisher, setListening, setLocalAddress, setPoolSize, setReceiveBufferSize, setSoReceiveBufferSize, setSoTimeout, setTaskExecutor
Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, isObserved, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisher
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
destroy, doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, 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.support.management.IntegrationManagement
destroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedType
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
UnicastReceivingChannelAdapter
public UnicastReceivingChannelAdapter(int port) Constructs a UnicastReceivingChannelAdapter that listens on the specified port.- Parameters:
port
- The 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.
-
-
Method Details
-
setLengthCheck
public void setLengthCheck(boolean lengthCheck) - Parameters:
lengthCheck
- if true, the incoming packet is expected to have a four byte binary length header.- Since:
- 5.0
-
setSocketCustomizer
Set a customizer to further configure the socket after creation.- Parameters:
socketCustomizer
- the customizer.- Since:
- 5.3.3
-
isLongLived
public boolean isLongLived() -
getPort
public int getPort()- Overrides:
getPort
in classAbstractInternetProtocolReceivingChannelAdapter
- Returns:
- The port on which this receiver is listening.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classMessageProducerSupport
-
run
public void run() -
sendAck
-
asyncSendMessage
-
doSend
-
receive
- Throws:
IOException
-
setSocket
- Parameters:
socket
- the socket to set
-
getTheSocket
-
getSocket
-
setSocketAttributes
Sets timeout and receive buffer size; calls the socket customizer.- Parameters:
socket
- The socket.- Throws:
SocketException
- Any socket exception.
-
doStop
protected void doStop()Description copied from class:MessageProducerSupport
Take no action by default. Subclasses may override this if they need lifecycle-managed behavior.- Overrides:
doStop
in classAbstractInternetProtocolReceivingChannelAdapter
-
setSoSendBufferSize
public void setSoSendBufferSize(int soSendBufferSize) - Parameters:
soSendBufferSize
- The send buffer size.- See Also:
-
setLookupHost
public void setLookupHost(boolean lookupHost) -
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classIntegrationObjectSupport
-