Lifecycle of a work item
The Status
field of a work item records the current state of its lifecycle. The
work queue framework manages this field and the lifecycle of work items
for your writer and workers. The following diagram illustrates the lifecycle.
A work
item begins life after the writer selects the units of work for a batch
and returns an iterator for the collection. The framework then creates
work items that reference the units of work for a batch. The initial
state of a work item is available.
At the time the framework checks out a quota of work items for a worker,
the state of the work items becomes checkedout.
The framework then hands the quota of work items to the worker one at
a time. After a worker finishes processing a work item successfully,
the framework deletes it from the work queue and updates the statistics
in the process history for the batch.
Returning work items to the work queue
Sometimes a worker cannot finish processing
a work item successfully. For example, a network resource may be temporarily
unavailable. Or, a concurrent data change exception (CDCE) can occur
if multiple workers simultaneously update common entity data in the domain
graphs of two separate units of work. Whenever errors occur, the worker
throws an exception to return the work item to the work queue as available again.
Whenever a worker returns a work item
to the work queue, PolicyCenter
increments the Attempts
property on the work item. If the value of Attempts remains below the retry
limit for the worker, the state of the work item remains available. The work item is subsequently
checked out in a quota for the same or another worker. If the temporary
error condition clears, the next worker completes it successfully and
PolicyCenter removes the work
item from the work queue.
Work items that fail
Whenever a worker returns a checked out work item and the Attempts
property exceeds the work item retry limit, the state of the work item becomes
failed. Failed work items end their lifecycle in this state. Workers
ignore items with a status of failed and no longer attempt to process them.
Someone must determine the reason for the failure of a work item and take corrective action.
They can then remove the failed work item from the work queue.
See also
- For more information on the lifecycle of work queues, see Troubleshooting work queues.
