Class AbstractPollingEndpoint
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.AbstractPollingEndpoint
- All Implemented Interfaces:
- Aware,- BeanClassLoaderAware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Lifecycle,- Phased,- SmartLifecycle,- ComponentSourceAware,- ExpressionCapable,- NamedComponent,- ManageableLifecycle,- ManageableSmartLifecycle
- Direct Known Subclasses:
- PollingConsumer,- SourcePollingChannelAdapter
public abstract class AbstractPollingEndpoint
extends AbstractEndpoint
implements BeanClassLoaderAware
An 
AbstractEndpoint extension for Polling Consumer pattern basics.
 The standard polling logic is based on a periodic task scheduling according the provided
 Trigger.
 When this endpoint is treated as isReactive(), a polling logic is turned into a
 Flux.generate(java.util.function.Consumer) and Mono.delay(Duration) combination based on the
 SimpleTriggerContext state.- Author:
- Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan, Andreas Baer, Christian Tzolov, Ngoc Nhan
- 
Field SummaryFieldsFields inherited from class org.springframework.integration.endpoint.AbstractEndpointlifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidAdd the advice chain to the component that responds toreceiveMessage()calls.protected voiddonePollingTask(Message<?> message) The callback of a received message (if any) after the polling task is done.protected voiddoStart()Subclasses must implement this method with the start behavior.protected voiddoStop()Subclasses must implement this method with the stop behavior.protected ClassLoaderReturn the default error channel if the error handler is explicitly provided, and it is aMessagePublishingErrorHandler.longprotected reactor.core.publisher.Flux<Message<?>> protected Objectprotected StringReturn the key under which the resource will be made available as an attribute on theIntegrationResourceHolder.protected ObjectReturn a resource (MessageSource etc.) to bind when using transaction synchronization.protected Executorprotected abstract voidhandleMessage(Message<?> message) Handle a message.protected booleanprotected booleanisReceiveOnlyAdvice(Advice advice) Return true if this advice should be applied only to thereceiveMessage()operation rather than the whole poll.protected booleanprotected voidmessageReceived(IntegrationResourceHolder holder, Message<?> message) protected voidonInit()Subclasses may implement this for initialization logic.protected abstract Message<?> Obtain the next message (if one is available).voidsetAdviceChain(List<Advice> adviceChain) voidsetBeanClassLoader(ClassLoader classLoader) voidsetErrorHandler(ErrorHandler errorHandler) voidsetMaxMessagesPerPoll(long maxMessagesPerPoll) Configure a cap for messages to poll from the source per scheduling cycle.protected voidsetReceiveMessageSource(Object source) voidsetTaskExecutor(Executor taskExecutor) voidsetTransactionSynchronizationFactory(TransactionSynchronizationFactory transactionSynchronizationFactory) voidsetTrigger(Trigger trigger) Methods 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, getComponentDescription, getComponentName, getComponentSource, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
- 
Field Details- 
DEFAULT_POLLING_PERIODpublic static final long DEFAULT_POLLING_PERIODA default polling period forPeriodicTrigger.- See Also:
 
 
- 
- 
Constructor Details- 
AbstractPollingEndpointpublic AbstractPollingEndpoint()
 
- 
- 
Method Details- 
setTaskExecutor
- 
getTaskExecutor
- 
isSyncExecutorprotected boolean isSyncExecutor()
- 
setTrigger
- 
setAdviceChain
- 
setMaxMessagesPerPollConfigure a cap for messages to poll from the source per scheduling cycle. A negative number means retrieve unlimited messages until theMessageSourcereturnsnull. Zero means do not poll for any records - it can be considered as pausing if 'maxMessagesPerPoll' is later changed to a non-zero value. The polling cycle may exit earlier if the source returns null for the currentreceivecall.- Parameters:
- maxMessagesPerPoll- the number of messages to poll per schedule.
 
- 
getMaxMessagesPerPollpublic long getMaxMessagesPerPoll()
- 
setErrorHandler
- 
setBeanClassLoader- Specified by:
- setBeanClassLoaderin interface- BeanClassLoaderAware
 
- 
setTransactionSynchronizationFactorypublic void setTransactionSynchronizationFactory(TransactionSynchronizationFactory transactionSynchronizationFactory) 
- 
getDefaultErrorChannelReturn the default error channel if the error handler is explicitly provided, and it is aMessagePublishingErrorHandler.- Returns:
- the channel or null.
- Since:
- 4.3
 
- 
getBeanClassLoader
- 
isReceiveOnlyAdviceReturn true if this advice should be applied only to thereceiveMessage()operation rather than the whole poll.- Parameters:
- advice- The advice.
- Returns:
- true to only advise the receiveoperation.
 
- 
applyReceiveOnlyAdviceChainAdd the advice chain to the component that responds toreceiveMessage()calls.- Parameters:
- chain- the advice chain- Collection.
 
- 
isReactiveprotected boolean isReactive()
- 
getPollingFlux
- 
getReceiveMessageSource
- 
setReceiveMessageSource
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- AbstractEndpoint
 
- 
doStartprotected void doStart()Description copied from class:AbstractEndpointSubclasses must implement this method with the start behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Specified by:
- doStartin class- AbstractEndpoint
 
- 
messageReceived
- 
donePollingTask
- 
doStopprotected void doStop()Description copied from class:AbstractEndpointSubclasses must implement this method with the stop behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Specified by:
- doStopin class- AbstractEndpoint
 
- 
receiveMessageObtain the next message (if one is available). MAY return null if no message is immediately available.- Returns:
- The message or null.
 
- 
handleMessageHandle a message.- Parameters:
- message- The message.
 
- 
getResourceToBindReturn a resource (MessageSource etc.) to bind when using transaction synchronization.- Returns:
- The resource, or null if transaction synchronization is not required.
 
- 
getResourceKeyReturn the key under which the resource will be made available as an attribute on theIntegrationResourceHolder. The defaultExpressionEvaluatingTransactionSynchronizationProcessormakes this attribute available as a variable in SpEL expressions.- Returns:
- The key, or null (default) if the resource shouldn't be made available as a attribute.
 
 
-