pwargulak opened a new pull request, #6753:
URL: https://github.com/apache/fineract/pull/6753

   ## Description
   
   [FINERACT-3004](https://issues.apache.org/jira/browse/FINERACT-3004). Builds 
on #6746 (FINERACT-3000), which touches the same Working Capital worker 
configuration; only the last commit is new here.
   
   When a business step failed for one loan during a scheduled Loan COB or 
Working Capital Loan COB run, `COBBusinessStepServiceImpl#run` (which joins the 
chunk transaction) marked the chunk transaction rollback-only. The retry then 
ran in that same transaction, the loan was skipped, and Spring Batch 6's 
`ChunkOrientedStep` rolled the whole chunk back at the end without an 
exception. Every loan of the chunk kept its `LOAN_COB_CHUNK_PROCESSING` lock 
with no error, none was closed, and the job reported success.
   
   This change brings back what was intended (thanks @adamsaghy for the 
description on the dev list): the loans of a chunk are retried in separate 
transactions, the ones that still fail have the exception recorded on their 
lock, and a later run or catch-up picks those up.
   
   - new `ItemTransactionProcessor` (`fineract-cob`): processes and writes one 
item in a `REQUIRES_NEW` transaction. The item is loaded again inside that 
transaction. Its business step writes, its last closed business date and the 
release of its lock commit or roll back together, so the invariant 
FINERACT-2684 keeps (business-step writes never commit without the loan being 
marked as closed) holds per loan;
   - `LoanCOBWorkerConfiguration` and 
`WorkingCapitalLoanCOBWorkerConfiguration` wrap their processor and existing 
writer in it; the step's writer is a no-op;
   - a failed business step no longer dooms the chunk transaction, so the item 
listener's error write to the lock goes through, and Batch's retry starts from 
a clean transaction each time;
   - inline COB is unchanged (it already runs per loan).
   
   *Trade-off: one commit per loan instead of one per chunk.*
   
   Tests:
   - new `ItemTransactionProcessorTest` (4): commit on success, rollback and 
the original exception on a processing or write failure, step listener 
delegation;
   - `CobStepListenerRegistrationTest` covers `ItemTransactionProcessor`;
   - new `LoanCobBusinessStepFailureTest` and 
`FeignWorkingCapitalLoanCobBusinessStepFailureTest`: two loans of one chunk, 
one whose step must post on a closed date, one with no accounting. The second 
must be closed for the COB date, and (term loans, where locks can be read) the 
first one's lock must carry the error. Both fail on `develop`.
   
   
   ## Checklist
   
   - [x] Write the commit message as per [our 
guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests)
   - [x] Acknowledge that we will not review PRs that are not passing the build 
_("green")_ - it is your responsibility to get a proposed PR to pass the build, 
not primarily the project's maintainers.
   - [x] Create/update [unit or integration 
tests](https://fineract.apache.org/docs/current/#_testing) for verifying the 
changes made.
   - [x] Follow our [coding 
conventions](https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions).
   - [ ] Add required Swagger annotation and update API documentation at 
fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with 
details of any API changes
   - [x] [This PR must not be a "code 
dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit).
 Large changes can be made in a branch, with assistance. Ask for help on the 
[developer mailing list](https://fineract.apache.org/#contribute).
   - [x] If merging this PR resolves a JIRA issue, I will mark that issue as 
resolved and set "Fix Version/s" appropriately.
   - [x] I followed the [AI 
Policy](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#ai-policy).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to