adamsaghy commented on code in PR #3255:
URL: https://github.com/apache/fineract/pull/3255#discussion_r1229609010
##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/ApplyLoanLockTasklet.java:
##########
@@ -41,13 +43,43 @@
@RequiredArgsConstructor
public class ApplyLoanLockTasklet implements Tasklet {
+ private static final int NUMBER_OF_RETRIES = 3;
private final FineractProperties fineractProperties;
private final LoanLockingService loanLockingService;
private final RetrieveLoanIdService retrieveLoanIdService;
private final CustomJobParameterResolver customJobParameterResolver;
@Override
public RepeatStatus execute(@NotNull StepContribution contribution,
@NotNull ChunkContext chunkContext) throws Exception {
+ // TODO: Need to check Spring Batch based retry logic in the future,
with using RepeatStatus.CONTINUABLE to
+ // retry tasklet execution rather than do while. Currently with
RepeatStatus.CONTINUABLE we are getting
+ // transaction rollback exception.
+ int numberOfExecutions = 0;
+ do {
+ try {
+ applyLoanLock(contribution);
+ return RepeatStatus.FINISHED;
+ } catch (Exception e) {
+ if (++numberOfExecutions > NUMBER_OF_RETRIES) {
+ String message = "There was an error applying lock to loan
accounts.";
+ log.error("{}", message, e);
+ throw new LoanLockCannotBeAppliedException(message, e);
+ } else {
+ waitBeforeRetry();
+ }
+ }
+ } while (true);
+ }
+
+ private void waitBeforeRetry() {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ log.info("{}", "Error applying loan lock.", e);
Review Comment:
Should be rethrown the error here...and logging an error should be used the
ERROR level, but at least the WARNING (but usually rather ERROR level)
--
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]