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, Christian Tzolov
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFieldsFields inherited from class org.springframework.integration.endpoint.AbstractEndpointlifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionUnicastReceivingChannelAdapter(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 SummaryModifier and TypeMethodDescriptionprotected booleanasyncSendMessage(DatagramPacket packet) protected voiddoSend(DatagramPacket packet) protected voiddoStop()Take no action by default.Subclasses may implement this method to provide component type information.intgetPort()protected DatagramSocketbooleanprotected voidonInit()Subclasses may implement this for initialization logic.protected DatagramPacketreceive()voidrun()protected voidvoidsetLengthCheck(boolean lengthCheck) voidsetLookupHost(boolean lookupHost) voidsetSocket(DatagramSocket socket) protected voidsetSocketAttributes(DatagramSocket socket) Sets timeout and receive buffer size; calls the socket customizer.voidsetSocketCustomizer(SocketCustomizer socketCustomizer) Set a customizer to further configure the socket after creation.voidsetSoSendBufferSize(int soSendBufferSize) Methods inherited from class org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdaptercheckTaskExecutor, doStart, getApplicationEventPublisher, getLocalAddress, getReceiveBufferSize, getSoReceiveBufferSize, getSoTimeout, getTaskExecutor, isListening, setApplicationEventPublisher, setListening, setLocalAddress, setPoolSize, setReceiveBufferSize, setSoReceiveBufferSize, setSoTimeout, setTaskExecutorMethods inherited from class org.springframework.integration.endpoint.MessageProducerSupportafterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, isObserved, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisherMethods inherited from class org.springframework.integration.endpoint.AbstractEndpointdestroy, doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementdestroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentNameMethods inherited from interface org.springframework.scheduling.SchedulingAwareRunnablegetQualifier
- 
Field Details- 
lock
 
- 
- 
Constructor Details- 
UnicastReceivingChannelAdapterpublic UnicastReceivingChannelAdapter(int port) Constructs a UnicastReceivingChannelAdapter that listens on the specified port.- Parameters:
- port- The port.
 
- 
UnicastReceivingChannelAdapterpublic 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- 
setLengthCheckpublic void setLengthCheck(boolean lengthCheck) - Parameters:
- lengthCheck- if true, the incoming packet is expected to have a four byte binary length header.
- Since:
- 5.0
 
- 
setSocketCustomizerSet a customizer to further configure the socket after creation.- Parameters:
- socketCustomizer- the customizer.
- Since:
- 5.3.3
 
- 
isLongLivedpublic boolean isLongLived()
- 
getPortpublic int getPort()- Overrides:
- getPortin class- AbstractInternetProtocolReceivingChannelAdapter
- Returns:
- The port on which this receiver is listening.
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- MessageProducerSupport
 
- 
runpublic void run()
- 
sendAck
- 
asyncSendMessage
- 
doSend
- 
receive- Throws:
- IOException
 
- 
setSocket- Parameters:
- socket- the socket to set
 
- 
getTheSocket
- 
getSocket
- 
setSocketAttributesSets timeout and receive buffer size; calls the socket customizer.- Parameters:
- socket- The socket.
- Throws:
- SocketException- Any socket exception.
 
- 
doStopprotected void doStop()Description copied from class:MessageProducerSupportTake no action by default. Subclasses may override this if they need lifecycle-managed behavior.- Overrides:
- doStopin class- AbstractInternetProtocolReceivingChannelAdapter
 
- 
setSoSendBufferSizepublic void setSoSendBufferSize(int soSendBufferSize) - Parameters:
- soSendBufferSize- The send buffer size.
- See Also:
 
- 
setLookupHostpublic void setLookupHost(boolean lookupHost) 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- IntegrationObjectSupport
 
 
-