Support partial processing of a batch, without having to interrupt or manually restart, but enabling corrective action to be taken after the process has finished to complete the processing of failed records. A batch that is going to fail completely can be be identified as soon as possible, but one which is substantially alright can run as far as possible to prevent costly duplication. Records that are skipped are reported in such a way that they can be easily identified by the Operator and / or Business User and a new batch created to finish the original goal. By the same token, in the case of an aborted batch where a minority of records are processed successfully first time, it should be possible to identify the successful records and exclude them from data presented on restart.
The vanilla flow proceeds as follows:
The batch cannot skip all records. After each failure the decision about whether to coninue has to be made:
The transient failure is really just a sub-type of fatal case. It is treated differently by the retry framework but not necessarily by the vanilla batch.
public void iterate(RepeatCallback callback) { ... try { result = callback.doInIteration(context); } catch (Exception e) { handleException(e); // Maybe re-throw, maybe not... } ... }
If the callback was transactional it has already rolled back. If the whole iterate() was transactional we need to rethrow