Package org.nuxeo.ecm.core.work.api
Interface WorkManager
- All Known Implementing Classes:
StreamWorkManager
,WorkManagerImpl
public interface WorkManager
A
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.
- Since:
- 5.6
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The scheduling policy to use when adding a work instance usingschedule(Work, Scheduling)
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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 queuesvoid
enableProcessing
(String queueId, boolean value) Set processing for a given queue id.find
(String workId, Work.State state) Deprecated.since 10.2 not scalablegetCategoryQueueId
(String category) Gets the queue id used for a given work category.getMetrics
(String queueId) Gets the metrics for thequeueId
getWorkQueueDescriptor
(String queueId) Gets the work queue descriptor for a given queue id.Lists the ids of the existing work queues.getWorkState
(String workId) Deprecated.void
init()
Starts up thisWorkManager
and attempts to resume work previously suspended and saved atshutdown(long, java.util.concurrent.TimeUnit)
time.boolean
Is processing enabled for at least one queueboolean
isProcessingEnabled
(String queueId) Is processing enabled for a given queue id.boolean
isQueuingEnabled
(String queueId) Is queuing enabled for a given queue id.boolean
listWork
(String queueId, Work.State state) Deprecated.since 10.2 not scalablelistWorkIds
(String queueId, Work.State state) Deprecated.since 10.2 not scalablevoid
Schedules work for execution at a later time.void
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
Shuts down thisWorkManager
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.boolean
-
Method Details
-
schedule
Schedules work for execution at a later time.This method is identical to
schedule(Work, boolean)
withafterCommit = false
.- Parameters:
work
- the work to execute
-
schedule
Schedules work for execution at a later time, after the current transaction (if any) has committed.- Parameters:
work
- the work to executeafterCommit
- iftrue
and the work is scheduled, it will only be run after the current transaction (if any) has committed
-
schedule
Schedules work for execution at a later time, with a specific scheduling policy.This method is identical to
schedule(Work, Scheduling, boolean)
withafterCommit = false
.- Parameters:
work
- the work to executescheduling
- the scheduling policy- See Also:
-
schedule
Schedules work for execution at a later time, with a specific scheduling policy.- Parameters:
work
- the work to executescheduling
- the scheduling policyafterCommit
- iftrue
and the work is scheduled, it will only be run after the current transaction (if any) has committed- See Also:
-
getWorkQueueIds
Lists the ids of the existing work queues.- Returns:
- the list of queue ids
-
getCategoryQueueId
Gets the queue id used for a given work category.- Parameters:
category
- the category- Returns:
- the queue id
-
getWorkQueueDescriptor
Gets the work queue descriptor for a given queue id.- Parameters:
queueId
- the queue id- Returns:
- the work queue descriptor, or
null
-
isProcessingEnabled
boolean isProcessingEnabled()Is processing enabled for at least one queue- Since:
- 8.3
-
supportsProcessingDisabling
boolean supportsProcessingDisabling()- Returns:
- true if the implementation supports processing disabling
- Since:
- 10.3
-
enableProcessing
void enableProcessing(boolean value) Set processing for all queues- Since:
- 8.3
-
isProcessingEnabled
Is processing enabled for a given queue id.- Since:
- 8.3
-
enableProcessing
Set processing for a given queue id.- Since:
- 8.3
-
isQueuingEnabled
Is queuing enabled for a given queue id.- Since:
- 8.3
-
init
void init()Starts up thisWorkManager
and attempts to resume work previously suspended and saved atshutdown(long, java.util.concurrent.TimeUnit)
time. -
shutdownQueue
Shuts down a work queue and attempts to suspend and save the running and scheduled work instances.- Parameters:
queueId
- the queue idtimeout
- the time to waitunit
- the timeout unit- Returns:
true
if shutdown is done,false
if there are still some threads executing after the timeout- Throws:
InterruptedException
-
shutdown
Shuts down thisWorkManager
and attempts to suspend and save the running and scheduled work instances.- Parameters:
timeout
- the time to waitunit
- the timeout unit- Returns:
true
if shutdown is done,false
if there are still some threads executing after the timeout- Throws:
InterruptedException
-
getMetrics
Gets the metrics for thequeueId
- Since:
- 8.3
-
awaitCompletion
Waits for completion of work in a given queue.- Parameters:
queueId
- the queue idtimeout
- the time to waitunit
- the timeout unit- Returns:
true
if all work completed in the queue, orfalse
if there is still some non-completed work after the timeout- Throws:
InterruptedException
-
awaitCompletion
Waits for completion of all work.- Parameters:
timeout
- the time to waitunit
- the timeout unit- Returns:
true
if all work completed, orfalse
if there is still some non-completed work after the timeout- Throws:
InterruptedException
-
isStarted
boolean isStarted()- Returns:
true
if active- Since:
- 6.0
- See Also:
-
getWorkState
Deprecated.- Parameters:
workId
- the id of the work to find- Returns:
- the work state, or
null
if not found - Since:
- 5.8
-
find
Deprecated.since 10.2 not scalableFinds a work instance. -
listWork
Deprecated.since 10.2 not scalableLists the work instances in a given queue in a defined state. -
listWorkIds
Deprecated.since 10.2 not scalableLists the work ids in a given queue in a defined state.
-