public abstract class AbstractPollingEndpoint extends AbstractEndpoint implements BeanClassLoaderAware
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(Consumer)
and Mono.delay(Duration)
combination based on the
SimpleTriggerContext
state.Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_POLLING_PERIOD
A default polling period for
PeriodicTrigger . |
lifecycleCondition, lifecycleLock
EXPRESSION_PARSER, logger
DEFAULT_PHASE
Constructor and Description |
---|
AbstractPollingEndpoint() |
Modifier and Type | Method and Description |
---|---|
protected void |
applyReceiveOnlyAdviceChain(Collection<Advice> chain)
Add the advice chain to the component that responds to
receiveMessage() calls. |
protected void |
doStart()
Subclasses must implement this method with the start behavior.
|
protected void |
doStop()
Subclasses must implement this method with the stop behavior.
|
protected ClassLoader |
getBeanClassLoader() |
MessageChannel |
getDefaultErrorChannel()
Return the default error channel if the error handler is explicitly provided and
it is a
MessagePublishingErrorHandler . |
protected reactor.core.publisher.Flux<Message<?>> |
getPollingFlux() |
protected Object |
getReceiveMessageSource() |
protected String |
getResourceKey()
Return the key under which the resource will be made available as an
attribute on the
IntegrationResourceHolder . |
protected Object |
getResourceToBind()
Return a resource (MessageSource etc) to bind when using transaction
synchronization.
|
protected Executor |
getTaskExecutor() |
protected abstract void |
handleMessage(Message<?> message)
Handle a message.
|
protected boolean |
isReactive() |
protected boolean |
isReceiveOnlyAdvice(Advice advice)
Return true if this advice should be applied only to the
receiveMessage() operation
rather than the whole poll. |
protected boolean |
isSyncExecutor() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
protected abstract Message<?> |
receiveMessage()
Obtain the next message (if one is available).
|
void |
setAdviceChain(List<Advice> adviceChain) |
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setErrorHandler(ErrorHandler errorHandler) |
void |
setMaxMessagesPerPoll(long maxMessagesPerPoll) |
protected void |
setReceiveMessageSource(Object source) |
void |
setTaskExecutor(Executor taskExecutor) |
void |
setTransactionSynchronizationFactory(TransactionSynchronizationFactory transactionSynchronizationFactory) |
void |
setTrigger(Trigger trigger) |
destroy, doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
public static final long DEFAULT_POLLING_PERIOD
PeriodicTrigger
.public void setTaskExecutor(Executor taskExecutor)
protected Executor getTaskExecutor()
protected boolean isSyncExecutor()
public void setTrigger(Trigger trigger)
public void setMaxMessagesPerPoll(long maxMessagesPerPoll)
public void setErrorHandler(ErrorHandler errorHandler)
public void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader
in interface BeanClassLoaderAware
public void setTransactionSynchronizationFactory(TransactionSynchronizationFactory transactionSynchronizationFactory)
public MessageChannel getDefaultErrorChannel()
MessagePublishingErrorHandler
.protected ClassLoader getBeanClassLoader()
protected boolean isReceiveOnlyAdvice(Advice advice)
receiveMessage()
operation
rather than the whole poll.advice
- The advice.protected void applyReceiveOnlyAdviceChain(Collection<Advice> chain)
receiveMessage()
calls.chain
- the advice chain Collection
.protected boolean isReactive()
protected reactor.core.publisher.Flux<Message<?>> getPollingFlux()
protected Object getReceiveMessageSource()
protected void setReceiveMessageSource(Object source)
protected void onInit()
IntegrationObjectSupport
onInit
in class AbstractEndpoint
protected void doStart()
AbstractEndpoint
AbstractEndpoint.lifecycleLock
.doStart
in class AbstractEndpoint
protected void doStop()
AbstractEndpoint
AbstractEndpoint.lifecycleLock
.doStop
in class AbstractEndpoint
protected abstract Message<?> receiveMessage()
protected abstract void handleMessage(Message<?> message)
message
- The message.protected Object getResourceToBind()
protected String getResourceKey()
IntegrationResourceHolder
. The default
ExpressionEvaluatingTransactionSynchronizationProcessor
makes this attribute available as a variable in SpEL expressions.