Skip to content

Commit

Permalink
[CIRC-1950] Release v24.0.7 (#1374)
Browse files Browse the repository at this point in the history
* 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 d6c6d81)

* Update NEWS

* [maven-release-plugin] prepare release v24.0.7

* [maven-release-plugin] prepare for next development iteration
  • Loading branch information
roman-barannyk authored Nov 15, 2023
1 parent 175800e commit 663a410
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>mod-circulation</artifactId>
<groupId>org.folio</groupId>
<version>24.0.7-SNAPSHOT</version>
<version>24.0.8-SNAPSHOT</version>
<licenses>
<license>
<name>Apache License 2.0</name>
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/org/folio/circulation/services/EventPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,16 @@ public CompletableFuture<Result<LoanAndRelatedRecords>> 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());
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/api/loans/CheckOutByBarcodeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 663a410

Please sign in to comment.