Class AbstractPollingMessageSource<T,S>
java.lang.Object
io.awspring.cloud.sqs.listener.source.AbstractMessageConvertingMessageSource<T,S>
io.awspring.cloud.sqs.listener.source.AbstractPollingMessageSource<T,S>
- All Implemented Interfaces:
ConfigurableContainerComponent,IdentifiableContainerComponent,AcknowledgementProcessingMessageSource<T>,MessageSource<T>,PollingMessageSource<T>,TaskExecutorAware,Lifecycle,Phased,SmartLifecycle
- Direct Known Subclasses:
AbstractSqsMessageSource
public abstract class AbstractPollingMessageSource<T,S>
extends AbstractMessageConvertingMessageSource<T,S>
implements PollingMessageSource<T>, IdentifiableContainerComponent
Base
PollingMessageSource implementation with SmartLifecycle
capabilities.
Polling backpressure is handled the provided BackPressureHandler. The connected MessageSink should
use the provided MessageProcessingContext.getAcknowledgmentCallback() to signal each message processing
completion and enable further polling.
Message conversion capabilities are inherited by the AbstractMessageConvertingMessageSource superclass.
The AcknowledgementProcessor instance provides the AcknowledgementCallback to be set in the
MessageProcessingContext and executed downstream when applicable.
- Since:
- 3.0
- Author:
- Tomaz Fernandes
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigureMessageSource(ContainerOptions<?, ?> containerOptions) protected MessageProcessingContext<T>protected voiddoConfigure(ContainerOptions<?, ?> containerOptions) Override to configure subclasses.protected abstract CompletableFuture<Collection<S>>doPollForMessages(int messagesToRequest) protected voiddoStart()protected voiddoStop()protected AcknowledgementCallback<T>protected AcknowledgementProcessor<T>getId()Get the component id.protected StringbooleanreleaseUnusedPermits(int permits, Collection<Message<T>> msgs) voidsetAcknowledgementProcessor(AcknowledgementProcessor<T> acknowledgementProcessor) Set theAcknowledgementProcessorinstance that will process the message instances and provide theAcknowledgementCallback.voidsetAcknowledgementResultCallback(AsyncAcknowledgementResultCallback<T> acknowledgementResultCallback) Set theAsyncAcknowledgementResultCallbackthat will be executed after messages are acknowledged, usually by aAcknowledgementExecutor.voidsetBackPressureHandler(BackPressureHandler backPressureHandler) Set theBackPressureHandlerthat will be use to handle backpressure in this source.voidSet the component id.voidsetMessageSink(MessageSink<T> messageSink) Set theMessageSinkto be used as an output for thisMessageSource.voidsetPollingEndpointName(String pollingEndpointName) Set the endpoint name that will be polled by this source.voidsetTaskExecutor(TaskExecutor taskExecutor) Set the task executor.voidstart()voidstop()Methods inherited from class io.awspring.cloud.sqs.listener.source.AbstractMessageConvertingMessageSource
configure, convertMessage, convertMessages, getMessageConversionContext, setupAcknowledgementForConversionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.awspring.cloud.sqs.listener.ConfigurableContainerComponent
configureMethods inherited from interface org.springframework.context.SmartLifecycle
getPhase, isAutoStartup, stop
-
Constructor Details
-
AbstractPollingMessageSource
public AbstractPollingMessageSource()
-
-
Method Details
-
configureMessageSource
- Overrides:
configureMessageSourcein classAbstractMessageConvertingMessageSource<T,S>
-
doConfigure
Override to configure subclasses.- Parameters:
containerOptions- theContainerOptionsfor this source.
-
setId
Description copied from interface:IdentifiableContainerComponentSet the component id.- Specified by:
setIdin interfaceIdentifiableContainerComponent- Parameters:
id- the id.
-
setPollingEndpointName
Description copied from interface:PollingMessageSourceSet the endpoint name that will be polled by this source.- Specified by:
setPollingEndpointNamein interfacePollingMessageSource<T>- Parameters:
pollingEndpointName- the name.
-
setBackPressureHandler
Description copied from interface:PollingMessageSourceSet theBackPressureHandlerthat will be use to handle backpressure in this source.- Specified by:
setBackPressureHandlerin interfacePollingMessageSource<T>- Parameters:
backPressureHandler- the handler.
-
setAcknowledgementProcessor
Description copied from interface:AcknowledgementProcessingMessageSourceSet theAcknowledgementProcessorinstance that will process the message instances and provide theAcknowledgementCallback.- Specified by:
setAcknowledgementProcessorin interfaceAcknowledgementProcessingMessageSource<T>- Parameters:
acknowledgementProcessor- the processor instance.
-
setAcknowledgementResultCallback
public void setAcknowledgementResultCallback(AsyncAcknowledgementResultCallback<T> acknowledgementResultCallback) Description copied from interface:AcknowledgementProcessingMessageSourceSet theAsyncAcknowledgementResultCallbackthat will be executed after messages are acknowledged, usually by aAcknowledgementExecutor.- Specified by:
setAcknowledgementResultCallbackin interfaceAcknowledgementProcessingMessageSource<T>- Parameters:
acknowledgementResultCallback- the callback instance.
-
setTaskExecutor
Description copied from interface:TaskExecutorAwareSet the task executor.- Specified by:
setTaskExecutorin interfaceTaskExecutorAware- Parameters:
taskExecutor- the task executor.
-
setMessageSink
Description copied from interface:MessageSourceSet theMessageSinkto be used as an output for thisMessageSource.- Specified by:
setMessageSinkin interfaceMessageSource<T>- Parameters:
messageSink- the message sink.
-
getId
Description copied from interface:IdentifiableContainerComponentGet the component id.- Specified by:
getIdin interfaceIdentifiableContainerComponent- Returns:
- the id.
-
isRunning
public boolean isRunning() -
start
public void start() -
doStart
protected void doStart() -
doPollForMessages
-
releaseUnusedPermits
-
createContext
-
getAcknowledgementCallback
-
getPollingEndpointName
-
getAcknowledgmentProcessor
-
stop
public void stop() -
doStop
protected void doStop()
-