FINERACT-1724

- fixes the JPA exception which is raised when a message was redelivered and earlier all the loans got closed for that given partition.
This commit is contained in:
Peter Bagrij
2023-08-15 08:30:49 +02:00
committed by Arnold Gálovics
parent f12430752f
commit a45ff9a3e0
2 changed files with 27 additions and 3 deletions
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.LinkedBlockingQueue;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.cob.common.CustomJobParameterResolver;
import org.apache.fineract.cob.data.LoanCOBParameter;
import org.apache.fineract.cob.domain.LoanAccountLock;
@@ -33,6 +34,7 @@ import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.annotation.BeforeStep;
import org.springframework.batch.item.ExecutionContext;
@Slf4j
public class LoanItemReader extends AbstractLoanItemReader {
private final RetrieveLoanIdService retrieveLoanIdService;
@@ -61,9 +63,10 @@ public class LoanItemReader extends AbstractLoanItemReader {
loanIds = retrieveLoanIdService.retrieveAllNonClosedLoansByLastClosedBusinessDateAndMinAndMaxLoanId(loanCOBParameter,
customJobParameterResolver.getCustomJobParameterById(stepExecution, LoanCOBConstant.IS_CATCH_UP_PARAMETER_NAME)
.map(Boolean::parseBoolean).orElse(false));
List<Long> lockedByCOBChunkProcessingAccountIds = getLoanIdsLockedWithChunkProcessingLock(loanIds);
loanIds.retainAll(lockedByCOBChunkProcessingAccountIds);
if (loanIds.size() > 0) {
List<Long> lockedByCOBChunkProcessingAccountIds = getLoanIdsLockedWithChunkProcessingLock(loanIds);
loanIds.retainAll(lockedByCOBChunkProcessingAccountIds);
}
}
setRemainingData(new LinkedBlockingQueue<>(loanIds));
}