E - task payload type.public interface WorkQueue<E> extends DistributedPrimitive
 Work queue serves as a buffer allowing producers to add tasks and consumers
 to take tasks to process.
 
 In the system each task is tracked via its unique task identifier which is returned when a task is taken.
 Work queue guarantees that a task can be taken by only one consumer at a time. Once it finishes processing a
 consumer must invoke the complete method to mark the task(s) as completed.
 Tasks thus completed are removed from the queue. If a consumer unexpectedly terminates before it can complete
 all its tasks are returned back to the queue so that other consumers can pick them up. Since there is a distinct
 possibility that tasks could be processed more than once (under failure conditions), care should be taken to ensure
 task processing logic is idempotent.
DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERATION_TIMEOUT_MILLIS| Modifier and Type | Method and Description | 
|---|---|
CompletableFuture<Void> | 
addMultiple(Collection<E> items)
Adds a collection of tasks to the work queue. 
 | 
default CompletableFuture<Void> | 
addOne(E item)
Adds a single task to the work queue. 
 | 
CompletableFuture<Void> | 
complete(Collection<String> taskIds)
Completes a collection of tasks. 
 | 
default CompletableFuture<Void> | 
complete(String... taskIds)
Completes a collection of tasks. 
 | 
default DistributedPrimitive.Type | 
primitiveType()
Returns the type of primitive. 
 | 
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. 
 | 
default CompletableFuture<Task<E>> | 
take()
Picks up a single task from the work queue to work on. 
 | 
CompletableFuture<Collection<Task<E>>> | 
take(int maxItems)
Picks up multiple tasks from the work queue to work on. 
 | 
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListenersdefault DistributedPrimitive.Type primitiveType()
DistributedPrimitiveprimitiveType in interface DistributedPrimitiveCompletableFuture<Void> addMultiple(Collection<E> items)
items - collection of task itemsCompletableFuture<Collection<Task<E>>> take(int maxItems)
 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.
maxItems - maximum number of items to take from the queue. The actual number of tasks returned
 can be at the max this numberCompletableFuture<Void> complete(Collection<String> taskIds)
taskIds - ids of tasks to completeCompletableFuture<Void> registerTaskProcessor(Consumer<E> taskProcessor, int parallelism, Executor executor)
taskProcessor - task processing callbackparallelism - max tasks that can be processed in parallelexecutor - executor to use for processing the tasksCompletableFuture<Void> stopProcessing()
registerTaskProcessor call.CompletableFuture<WorkQueueStats> stats()
default CompletableFuture<Void> complete(String... taskIds)
taskIds - var arg list of task idsdefault CompletableFuture<Void> addOne(E item)
item - task itemdefault CompletableFuture<Task<E>> take()
 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.