Search in sources :

Example 1 with LoadFailedMessage

use of org.folio.service.holdings.message.LoadFailedMessage in project mod-kb-ebsco-java by folio-org.

the class HoldingsServiceImpl method loadingFailed.

@Override
public void loadingFailed(LoadFailedMessage message) {
    final UUID credentialsId = toUUID(message.getCredentialsId());
    final String tenantId = message.getTenantId();
    setStatusToFailed(credentialsId, tenantId, message.getErrorMessage()).thenAccept(o -> retryAfterDelayIfAttemptsLeft(message.getCredentialsId(), tenantId, loadHoldingsRetryDelay, o2 -> executeWithLock(START_LOADING_LOCK, () -> {
        final Integer totalCount = message.getTotalCount();
        final Integer totalPages = message.getTotalPages();
        return tryChangingStatusToInProgress(getStatusLoadingHoldings(totalCount, 0, totalPages, 0), credentialsId, tenantId).thenCompose(o3 -> transactionIdRepository.getLastTransactionId(credentialsId, tenantId).thenAccept(previousTransactionId -> loadServiceFacade.loadHoldings(getLoadHoldingsMessage(message, previousTransactionId)))).exceptionally(e -> {
            logger.error(FAILED_RETRY_LOADING_HOLDINGS_MESSAGE, e);
            return null;
        });
    })));
}
Also used : HoldingsLoadingStatusFactory.getStatusLoadingHoldings(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusLoadingHoldings) Arrays(java.util.Arrays) HoldingsMessage(org.folio.service.holdings.message.HoldingsMessage) DeltaReportCreatedMessage(org.folio.service.holdings.message.DeltaReportCreatedMessage) Autowired(org.springframework.beans.factory.annotation.Autowired) HoldingChangeType(org.folio.holdingsiq.model.HoldingChangeType) LoadStatusNameEnum(org.folio.rest.jaxrs.model.LoadStatusNameEnum) HOLDING_UPDATED_ADDED_COVERAGE(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_UPDATED_ADDED_COVERAGE) HoldingsStatusRepository(org.folio.repository.holdings.status.HoldingsStatusRepository) RetryStatus(org.folio.repository.holdings.status.retry.RetryStatus) HoldingsLoadingStatusFactory.getLoadStatusFailed(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getLoadStatusFailed) HoldingsLoadingStatusFactory.getStatusPopulatingStagingArea(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusPopulatingStagingArea) StringUtils(org.apache.commons.lang3.StringUtils) SnapshotCreatedMessage(org.folio.service.holdings.message.SnapshotCreatedMessage) HoldingsLoadingStatusFactory.getStatusCompleted(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusCompleted) Holding(org.folio.holdingsiq.model.Holding) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) HOLDING_ADDED(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_ADDED) Collectors(java.util.stream.Collectors) Future(io.vertx.core.Future) List(java.util.List) OffsetDateTime(java.time.OffsetDateTime) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) LoadStatusAttributes(org.folio.rest.jaxrs.model.LoadStatusAttributes) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) HOLDING_UPDATED(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_UPDATED) HoldingsServiceMessagesFactory.getLoadHoldingsMessage(org.folio.repository.holdings.HoldingsServiceMessagesFactory.getLoadHoldingsMessage) Producer(org.glassfish.jersey.internal.util.Producer) CompletableFuture(java.util.concurrent.CompletableFuture) HoldingsLoadingStatusFactory.getStatusNotStarted(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusNotStarted) Function(java.util.function.Function) ProcessInProgressException(org.folio.service.holdings.exception.ProcessInProgressException) ErrorUtil.createError(org.folio.rest.util.ErrorUtil.createError) Value(org.springframework.beans.factory.annotation.Value) HoldingInReport(org.folio.holdingsiq.model.HoldingInReport) HoldingsRepository(org.folio.repository.holdings.HoldingsRepository) DbHoldingInfo(org.folio.repository.holdings.DbHoldingInfo) SnapshotFailedMessage(org.folio.service.holdings.message.SnapshotFailedMessage) AsyncResult(io.vertx.core.AsyncResult) HOLDING_UPDATED_DELETED_COVERAGE(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_UPDATED_DELETED_COVERAGE) FutureUtils.mapVertxFuture(org.folio.util.FutureUtils.mapVertxFuture) FutureUtils.failedFuture(org.folio.util.FutureUtils.failedFuture) LoadFailedMessage(org.folio.service.holdings.message.LoadFailedMessage) Promise(io.vertx.core.Promise) DeltaReportMessage(org.folio.service.holdings.message.DeltaReportMessage) Vertx(io.vertx.core.Vertx) HoldingsLoadingStatus(org.folio.rest.jaxrs.model.HoldingsLoadingStatus) Integer.parseInt(java.lang.Integer.parseInt) Component(org.springframework.stereotype.Component) HoldingsId(org.folio.repository.holdings.HoldingsId) ChronoUnit(java.time.temporal.ChronoUnit) Lock(io.vertx.core.shareddata.Lock) LoadStatusInformation(org.folio.rest.jaxrs.model.LoadStatusInformation) RetryStatusRepository(org.folio.repository.holdings.status.retry.RetryStatusRepository) DateTimeFormatter(java.time.format.DateTimeFormatter) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) TransactionIdRepository(org.folio.repository.holdings.transaction.TransactionIdRepository) HOLDING_DELETED(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_DELETED) Handler(io.vertx.core.Handler) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID)

Aggregations

AsyncResult (io.vertx.core.AsyncResult)1 Future (io.vertx.core.Future)1 Handler (io.vertx.core.Handler)1 Promise (io.vertx.core.Promise)1 Vertx (io.vertx.core.Vertx)1 Lock (io.vertx.core.shareddata.Lock)1 Integer.parseInt (java.lang.Integer.parseInt)1 OffsetDateTime (java.time.OffsetDateTime)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ChronoUnit (java.time.temporal.ChronoUnit)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Set (java.util.Set)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1