public interface WorkManager
WorkManager
executes Work
instances asynchronously.
A Work
can be scheduled by calling schedule(org.nuxeo.ecm.core.work.api.Work)
.
Work is executed in a thread pool and a work queue that depends on the work's category.
Modifier and Type | Interface and Description |
---|---|
static class |
WorkManager.Scheduling
The scheduling policy to use when adding a work instance using
schedule(Work, Scheduling) . |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitCompletion(long timeout,
TimeUnit unit)
Waits for completion of all work.
|
boolean |
awaitCompletion(String queueId,
long timeout,
TimeUnit unit)
Waits for completion of work in a given queue.
|
void |
enableProcessing(boolean value)
Set processing for all queues
|
void |
enableProcessing(String queueId,
boolean value)
Set processing for a given queue id.
|
Work |
find(String workId,
Work.State state)
Finds a work instance.
|
String |
getCategoryQueueId(String category)
Gets the queue id used for a given work category.
|
WorkQueueMetrics |
getMetrics(String queueId)
Gets the metrics for the
queueId |
int |
getQueueSize(String queueId,
Work.State state)
Deprecated.
since 5.8,
|
WorkQueueDescriptor |
getWorkQueueDescriptor(String queueId)
Gets the work queue descriptor for a given queue id.
|
List<String> |
getWorkQueueIds()
Lists the ids of the existing work queues.
|
Work.State |
getWorkState(String workId)
Deprecated.
|
void |
init()
Starts up this
WorkManager and attempts to resume work previously suspended and saved at
shutdown(long, java.util.concurrent.TimeUnit) time. |
boolean |
isProcessingEnabled()
Is processing enabled for at least one queue
|
boolean |
isProcessingEnabled(String queueId)
Is processing enabled for a given queue id.
|
boolean |
isQueuingEnabled(String queueId)
Is queuing enabled for a given queue id.
|
boolean |
isStarted() |
List<Work> |
listWork(String queueId,
Work.State state)
Lists the work instances in a given queue in a defined state.
|
List<String> |
listWorkIds(String queueId,
Work.State state)
Lists the work ids in a given queue in a defined state.
|
void |
schedule(Work work)
Schedules work for execution at a later time.
|
void |
schedule(Work work,
boolean afterCommit)
Schedules work for execution at a later time, after the current transaction (if any) has committed.
|
void |
schedule(Work work,
WorkManager.Scheduling scheduling)
Schedules work for execution at a later time, with a specific scheduling policy.
|
void |
schedule(Work work,
WorkManager.Scheduling scheduling,
boolean afterCommit)
Schedules work for execution at a later time, with a specific scheduling policy.
|
boolean |
shutdown(long timeout,
TimeUnit unit)
Shuts down this
WorkManager and attempts to suspend and save the running and scheduled work instances. |
boolean |
shutdownQueue(String queueId,
long timeout,
TimeUnit unit)
Shuts down a work queue and attempts to suspend and save the running and scheduled work instances.
|
void schedule(Work work)
This method is identical to schedule(Work, boolean)
with afterCommit = false
.
work
- the work to executevoid schedule(Work work, boolean afterCommit)
work
- the work to executeafterCommit
- if true
and the work is scheduled, it will only be run after the current transaction
(if any) has committedvoid schedule(Work work, WorkManager.Scheduling scheduling)
This method is identical to schedule(Work, Scheduling, boolean)
with afterCommit = false
.
work
- the work to executescheduling
- the scheduling policyschedule(Work)
void schedule(Work work, WorkManager.Scheduling scheduling, boolean afterCommit)
work
- the work to executescheduling
- the scheduling policyafterCommit
- if true
and the work is scheduled, it will only be run after the current transaction
(if any) has committedschedule(Work)
List<String> getWorkQueueIds()
String getCategoryQueueId(String category)
category
- the categoryWorkQueueDescriptor getWorkQueueDescriptor(String queueId)
queueId
- the queue idnull
boolean isProcessingEnabled()
void enableProcessing(boolean value)
boolean isProcessingEnabled(String queueId)
void enableProcessing(String queueId, boolean value)
boolean isQueuingEnabled(String queueId)
void init()
WorkManager
and attempts to resume work previously suspended and saved at
shutdown(long, java.util.concurrent.TimeUnit)
time.boolean shutdownQueue(String queueId, long timeout, TimeUnit unit) throws InterruptedException
queueId
- the queue idtimeout
- the time to waitunit
- the timeout unittrue
if shutdown is done, false
if there are still some threads executing after the
timeoutInterruptedException
boolean shutdown(long timeout, TimeUnit unit) throws InterruptedException
WorkManager
and attempts to suspend and save the running and scheduled work instances.timeout
- the time to waitunit
- the timeout unittrue
if shutdown is done, false
if there are still some threads executing after the
timeoutInterruptedException
@Deprecated int getQueueSize(String queueId, Work.State state)
WorkQueueMetrics getMetrics(String queueId)
queueId
boolean awaitCompletion(String queueId, long timeout, TimeUnit unit) throws InterruptedException
queueId
- the queue idtimeout
- the time to waitunit
- the timeout unittrue
if all work completed in the queue, or false
if there is still some non-completed
work after the timeoutInterruptedException
boolean awaitCompletion(long timeout, TimeUnit unit) throws InterruptedException
timeout
- the time to waitunit
- the timeout unittrue
if all work completed, or false
if there is still some non-completed work after the
timeoutInterruptedException
boolean isStarted()
true
if activeComponent.applicationStarted(org.nuxeo.runtime.model.ComponentContext)
,
init()
,
shutdown(long, TimeUnit)
@Deprecated Work.State getWorkState(String workId)
workId
- the id of the work to findnull
if not foundWork find(String workId, Work.State state)
List<Work> listWork(String queueId, Work.State state)
List<String> listWorkIds(String queueId, Work.State state)
Copyright © 2017 Nuxeo. All rights reserved.