The Unit of Work Design Pattern
Overview
The Unit of Work (UOW) is a design pattern that helps maintain a list of objects affected by a business transaction, and coordinates the writing out of changes and the resolution of concurrency problems.
UOW for Start of the Day (SOD) Job
With the Mercury release of CL Loan, the UOW design pattern is now implemented for SOD job.
Key Concepts
- The existing SOD job is modified to include the UOW design.
- The UOW design pattern is not implemented for the whole SOD job chain. It is only implemented for the Start of the day dynamic job when the system is DAG-enabled, and for the Start of the day job when the system is not DAG-enabled.
- The UOW design is added to avoid the blockage due to failures in any of the contracts by ensuring that the SOD job runs for those contracts that have not failed. For example, say that the SOD job runs for 100 contracts. Now, if one contract fails, then the SOD job does not fail for the rest of the 99 contracts because of the UOW design implemented in it.
Example
Say if there are five loan contracts in a particular job, and one of the contract has interest calculation method set as null, then the interest accrual is not calculated for that loan contract as well as for the deposit and interest component associated with it, and because of this one contract, the whole batch job with all the contracts in it fails.
However, with the UOW design pattern implemented, if the interest calculation method is null for one contract and if that contract fails, the interest accrued for other contracts is still calculated, and the batch job does not fail.
It thus ensures that when a problem occurs with one loan contract, the entire batch job with all the other contracts in it does not fail.