use of org.folio.service.holdings.message.SnapshotCreatedMessage in project mod-kb-ebsco-java by folio-org.
the class HoldingsServiceImpl method snapshotCreated.
@Override
public void snapshotCreated(SnapshotCreatedMessage message) {
final String tenantId = message.getTenantId();
final UUID credentialsId = toUUID(message.getCredentialsId());
transactionIdRepository.getLastTransactionId(credentialsId, tenantId).thenApply(previousTransactionId -> {
if (!isTransactionIsAlreadyLoaded(message, previousTransactionId)) {
holdingsStatusRepository.update(getStatusLoadingHoldings(message.getTotalCount(), 0, message.getTotalPages(), 0), credentialsId, tenantId).thenCompose(o -> resetRetries(loadHoldingsRetryCount - 1, credentialsId, tenantId)).thenAccept(o -> loadServiceFacade.loadHoldings(getLoadHoldingsMessage(message, previousTransactionId))).exceptionally(e -> {
logger.error(FAILED_CREATE_SNAPSHOT_MESSAGE, e);
return null;
});
} else {
logger.info(SKIPPING_LOADING_SNAPSHOT_MESSAGE, message.getTransactionId());
holdingsStatusRepository.update(getStatusCompleted(0), credentialsId, tenantId);
}
return null;
});
}
Aggregations