Package io.datarouter.conveyor.queue
Class BaseBatchedLossyQueueConsumerConveyor<PK extends io.datarouter.model.key.primary.PrimaryKey<PK>,D extends io.datarouter.model.databean.Databean<PK,D>>
java.lang.Object
io.datarouter.conveyor.BaseConveyor
io.datarouter.conveyor.queue.BaseBatchedLossyQueueConsumerConveyor<PK,D>
- Type Parameters:
PK- Primary keyD- Databean
public abstract class BaseBatchedLossyQueueConsumerConveyor<PK extends io.datarouter.model.key.primary.PrimaryKey<PK>,D extends io.datarouter.model.databean.Databean<PK,D>> extends BaseConveyor
Drains the queue and stores the data in a buffer. When the buffer hits a set limit it will trigger the processing as
a batch. This implementation makes the best effort to process the buffer if the queue gets drained or it has been
interrupted.
NOTE: If the thread running the conveyor is killed or crashes before the processing of the buffer is
completed the messages are lost forever. Along side the conveyor there must be some backup implementation that
re-queues messages that are lost.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.datarouter.conveyor.BaseConveyor
BaseConveyor.ProcessBatchResult -
Field Summary
-
Constructor Summary
Constructors Constructor Description BaseBatchedLossyQueueConsumerConveyor(java.lang.String name, java.util.function.Supplier<java.lang.Boolean> shouldRun, QueueConsumer<PK,D> queueConsumer, io.datarouter.web.exception.ExceptionRecorder exceptionRecorder) -
Method Summary
Modifier and Type Method Description voidinterrupted()BaseConveyor.ProcessBatchResultprocessBatch()protected abstract voidprocessBuffer(java.util.List<D> databeans)
-
Constructor Details
-
BaseBatchedLossyQueueConsumerConveyor
public BaseBatchedLossyQueueConsumerConveyor(java.lang.String name, java.util.function.Supplier<java.lang.Boolean> shouldRun, QueueConsumer<PK,D> queueConsumer, io.datarouter.web.exception.ExceptionRecorder exceptionRecorder)
-
-
Method Details
-
processBatch
- Specified by:
processBatchin classBaseConveyor
-
interrupted
public void interrupted()- Overrides:
interruptedin classBaseConveyor
-
processBuffer
-