public class ExecutingWorkQueue<E> extends ExecutingDistributedPrimitive implements WorkQueue<E>
AsyncAtomicValue that executes asynchronous callbacks on a user provided
Executor.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
ExecutingWorkQueue(WorkQueue<E> delegateQueue,
Executor orderedExecutor,
Executor threadPoolExecutor) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
addMultiple(Collection<E> items)
Adds a collection of tasks to the work queue.
|
CompletableFuture<Void> |
complete(Collection<String> taskIds)
Completes a collection of tasks.
|
CompletableFuture<Void> |
registerTaskProcessor(Consumer<E> taskProcessor,
int parallelism,
Executor executor)
Registers a task processing callback to be automatically invoked when new tasks are
added to the work queue.
|
CompletableFuture<WorkQueueStats> |
stats()
Returns work queue statistics.
|
CompletableFuture<Void> |
stopProcessing()
Stops automatically processing tasks from work queue.
|
CompletableFuture<Collection<Task<E>>> |
take(int maxItems)
Picks up multiple tasks from the work queue to work on.
|
addStatusChangeListener, asyncFuture, destroy, removeStatusChangeListenerapplicationId, equals, hashCode, name, primitiveType, statusChangeListeners, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddOne, complete, primitiveType, takeaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListenerspublic CompletableFuture<Void> addMultiple(Collection<E> items)
WorkQueueaddMultiple in interface WorkQueue<E>items - collection of task itemspublic CompletableFuture<Collection<Task<E>>> take(int maxItems)
WorkQueue
Tasks that are taken remain invisible to other consumers as long as the consumer stays alive.
If a consumer unexpectedly terminates before completing the task,
the task becomes visible again to other consumers to process.
take in interface WorkQueue<E>maxItems - maximum number of items to take from the queue. The actual number of tasks returned
can be at the max this numberpublic CompletableFuture<Void> complete(Collection<String> taskIds)
WorkQueuepublic CompletableFuture<Void> registerTaskProcessor(Consumer<E> taskProcessor, int parallelism, Executor executor)
WorkQueueregisterTaskProcessor in interface WorkQueue<E>taskProcessor - task processing callbackparallelism - max tasks that can be processed in parallelexecutor - executor to use for processing the taskspublic CompletableFuture<Void> stopProcessing()
WorkQueueregisterTaskProcessor call.stopProcessing in interface WorkQueue<E>public CompletableFuture<WorkQueueStats> stats()
WorkQueue