Class BatchingAcknowledgementProcessor<T>
java.lang.Object
io.awspring.cloud.sqs.listener.acknowledgement.AbstractOrderingAcknowledgementProcessor<T>
io.awspring.cloud.sqs.listener.acknowledgement.BatchingAcknowledgementProcessor<T>
- All Implemented Interfaces:
AcknowledgementCallback<T>,AcknowledgementProcessor<T>,ExecutingAcknowledgementProcessor<T>,ConfigurableContainerComponent,IdentifiableContainerComponent,TaskExecutorAware,Lifecycle,Phased,SmartLifecycle
public class BatchingAcknowledgementProcessor<T>
extends AbstractOrderingAcknowledgementProcessor<T>
implements TaskExecutorAware
AcknowledgementProcessor implementation that adds the messages
to a BlockingQueue to be acknowledged according to ContainerOptions.getAcknowledgementInterval() and
ContainerOptions.getAcknowledgementThreshold().
The messages are constantly polled from the queue and added to a buffer. When a message is polled, the processor
checks the queue size against the configured threshold and sends batches for execution if the threshold is breached.
A separate scheduled thread is activated when the configured amount of time has passed between the last
acknowledgement execution. This thread then empties the buffer and sends all messages to execution.
All buffer access must be synchronized by the Lock.
When this processor is signaled to Lifecycle.stop(), it waits for up to
acknowledgementShutdownTimeout seconds for ongoing acknowledgement executions to complete. After that time,
it will cancel all executions and return the flow to the caller.- 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 io.awspring.cloud.sqs.listener.acknowledgement.BatchingAcknowledgementProcessor.BufferingAcknowledgementProcessor<T>protected TaskSchedulerprotected voiddoConfigure(ContainerOptions<?, ?> containerOptions) protected CompletableFuture<Void>doOnAcknowledge(Collection<Message<T>> messages) protected CompletableFuture<Void>doOnAcknowledge(Message<T> message) voiddoStart()voiddoStop()voidsetTaskExecutor(TaskExecutor taskExecutor) Set the task executor.Methods inherited from class io.awspring.cloud.sqs.listener.acknowledgement.AbstractOrderingAcknowledgementProcessor
configure, getAcknowledgementCallback, getId, getMessageGroupingFunction, isRunning, onAcknowledge, onAcknowledge, sendToExecutor, setAcknowledgementExecutor, setAcknowledgementResultCallback, setId, setMaxAcknowledgementsPerBatch, setMessageGroupingFunction, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycle
getPhase, isAutoStartup, stop
-
Constructor Details
-
BatchingAcknowledgementProcessor
public BatchingAcknowledgementProcessor()
-
-
Method Details
-
doConfigure
- Overrides:
doConfigurein classAbstractOrderingAcknowledgementProcessor<T>
-
setTaskExecutor
Description copied from interface:TaskExecutorAwareSet the task executor.- Specified by:
setTaskExecutorin interfaceTaskExecutorAware- Parameters:
taskExecutor- the task executor.
-
doOnAcknowledge
- Specified by:
doOnAcknowledgein classAbstractOrderingAcknowledgementProcessor<T>
-
doOnAcknowledge
- Specified by:
doOnAcknowledgein classAbstractOrderingAcknowledgementProcessor<T>
-
doStart
public void doStart()- Overrides:
doStartin classAbstractOrderingAcknowledgementProcessor<T>
-
createTaskScheduler
-
createAcknowledgementProcessor
protected io.awspring.cloud.sqs.listener.acknowledgement.BatchingAcknowledgementProcessor.BufferingAcknowledgementProcessor<T> createAcknowledgementProcessor() -
doStop
public void doStop()- Overrides:
doStopin classAbstractOrderingAcknowledgementProcessor<T>
-