Creating a custom work queue class
After you define a typecode for your custom work queue and possibly create a custom work item type for it, you are ready to create your custom work queue class. This class contains the programming logic for the writer and the workers of your work queue. You must derive your class from WorkQueueBase, and you generally must override the following two methods.
|
Logic for the writer, which selects units of work for a batch and returns an iterator for the result set |
|
Logic for the workers, which operates on a single unit of work selected by the writer |
The WorkQueueBase provides other methods that you can override such as shouldProcessItem. However, you can generally develop a successful custom work queue by overriding the two required methods findTargets and processWorkItem.
WorkQueueBase. See also
Custom work queue class declaration
In the declaration of your custom work queue class, you must include the extends clause to derive your work queue class from WorkQueueBase. Because the base class is a template class, your class declaration must specify the entity types for the unit of works and for the work items in your work queue.
The following example code declares a custom work queue type that has Activtiy as the target, or unit of work, type. It also declares that StandardWorkItem as the work queue type.
class MyWorkQueue extends WorkQueueBase <Activity, StandardWorkItem> { … }Custom work queue class constructor
You must implement a constructor in your custom work queue class. The constructor that
you implement calls the constructor in the WorkQueueBase class. Your
constructor associates the custom work queue class at runtime with its typecode in the
BatchProcessType typelist, its work queue item type, and its target
type.
The following example code is the constructor for a custom work queue. It associates the
class at runtime with its batch process typecode MyWorkQueue. The code
associates the work queue with the StandardWorkItem entity type. So,
the work queue shares its work queue table with many other work queues. The code
associates the work queue with the Activity entity type as its target
unit of work type. So, the writer and the workers operate on Activity
instances.
construct () {
super (typekey.BatchProcessType.TC_MYWORKQUEUE, StandardWorkItem, Activity)
}
Do not include any code in the constructor of your custom work queue other than calling the super class constructor.
