From 663a4102807c00204bf4b38629cffce2abf0a86a Mon Sep 17 00:00:00 2001 From: Roman Barannyk <53909129+roman-barannyk@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:33:03 +0200 Subject: [PATCH] [CIRC-1950] Release v24.0.7 (#1374) * CIRC-1950 publish check-out event asynchronously (#1373) * CIRC-1950 publish check-out event asynchronously * CIRC-1910 refactoring, fix test * CIRC-1910 add logging * CIRC-1910 update logging message * CIRC-1910 refactoring, add comments * CIRC-1910 remove error handling (cherry picked from commit d6c6d81f0d33b469ffad8e8ea686928a8ee8c0fa) * Update NEWS * [maven-release-plugin] prepare release v24.0.7 * [maven-release-plugin] prepare for next development iteration --- NEWS.md | 4 ++++ pom.xml | 2 +- .../circulation/services/EventPublisher.java | 17 ++++++++++------- .../java/api/loans/CheckOutByBarcodeTests.java | 3 ++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index 566553b06a..ff5cd6c4c6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +## 24.0.7 2023-11-15 + +* Asynchronously publish the ITEM_CHECKED_OUT event and ignore the result (CIRC-1950) + ## 24.0.6 2023-11-10 * Fix Hold Shelf Expiration to respect Closed Library Dates (CIRC-1893) diff --git a/pom.xml b/pom.xml index 7792ecad0d..af15b55cbf 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 mod-circulation org.folio - 24.0.7-SNAPSHOT + 24.0.8-SNAPSHOT Apache License 2.0 diff --git a/src/main/java/org/folio/circulation/services/EventPublisher.java b/src/main/java/org/folio/circulation/services/EventPublisher.java index 26ae33dbd8..d7f77774a3 100644 --- a/src/main/java/org/folio/circulation/services/EventPublisher.java +++ b/src/main/java/org/folio/circulation/services/EventPublisher.java @@ -105,13 +105,16 @@ public CompletableFuture> publishItemCheckedOutEve .ifPresent(json -> write(payloadJsonObject, GRACE_PERIOD_FIELD, json)); runAsync(() -> userRepository.getUser(loanAndRelatedRecords.getLoggedInUserId()) - .thenApplyAsync(r -> r.after(loggedInUser -> CompletableFuture.completedFuture( - Result.succeeded(pubSubPublishingService.publishEvent(LOG_RECORD.name(), mapToCheckOutLogEventContent(loanAndRelatedRecords, loggedInUser))))))); - - return pubSubPublishingService.publishEvent(ITEM_CHECKED_OUT.name(), payloadJsonObject.encode()) - .handle((result, error) -> handlePublishEventError(error, loanAndRelatedRecords)); - } - else { + .thenApplyAsync(r -> r.after(loggedInUser -> completedFuture( + succeeded(pubSubPublishingService.publishEvent(LOG_RECORD.name(), + mapToCheckOutLogEventContent(loanAndRelatedRecords, loggedInUser))))))); + + logger.info("publishItemCheckedOutEvent:: publishing ITEM_CHECKED_OUT event for loan {}", + loan.getId()); + // run ITEM_CHECKED_OUT event publishing asynchronously to prevent any impact on the performance of check-out + runAsync(() -> pubSubPublishingService.publishEvent(ITEM_CHECKED_OUT.name(), + payloadJsonObject.encode())); + } else { logger.error(FAILED_TO_PUBLISH_LOG_TEMPLATE, ITEM_CHECKED_OUT.name()); } diff --git a/src/test/java/api/loans/CheckOutByBarcodeTests.java b/src/test/java/api/loans/CheckOutByBarcodeTests.java index 724037515e..7637a1d664 100644 --- a/src/test/java/api/loans/CheckOutByBarcodeTests.java +++ b/src/test/java/api/loans/CheckOutByBarcodeTests.java @@ -1607,7 +1607,8 @@ void checkOutShouldNotFailIfEventPublishingFailsWithBadRequestError() { final IndividualResource steve = usersFixture.steve(); FakePubSub.setFailPublishingWithBadRequestError(true); - checkOutFixture.attemptCheckOutByBarcode(200, + // since ITEM_CHECKED_OUT event is published asynchronously it doesn't affect check-out response + checkOutFixture.checkOutByBarcode( new CheckOutByBarcodeRequestBuilder() .forItem(smallAngryPlanet) .to(steve)