Creating JobWork
The most important goal of a BatchJob class is to return an instance of
JobWork describing what work should be done
(ThreadWorkUnits) and have that work split into manageable chunks
(ThreadWork) that can be processed by a single
ThreadWorker.
Most commonly, ThreadWorkUnits contain only the ID values of the entities to
be processed. For example, one can envision a process that performs an operation on a
set of accounts. In general, one would expect that each ThreadWorkUnit
would contain a single AccountId. The
ThreadWorker objects would then be constructed in such a way that
when asked to execute for a ThreadWorkUnit it would pull out the
embedded AccountId and then perform the required business function.
There are convenience methods available from the AbstractBatchJob that make it
easier to create JobWork instances. For example, the
createJobWorkForEntityQuery(Query) method will accept a query
returning BusinessEntity instances, and create a JobWork
instance containing the appropriate number of ThreadWork
instances, each containing (notwithstanding rounding) the same number of
ThreadWorkUnits.
