Last active
January 4, 2021 13:11
-
-
Save JohnChangUK/bf19b79b6ef87effa15576356de3e90b to your computer and use it in GitHub Desktop.
TransactionEventConsumer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void consumeEvent(TransactionEvent event) { | |
Mono.fromRunnable( | |
() -> orderPurchaseRepository.findById(event.getOrderId()) | |
.ifPresent(order -> { | |
setStatus(event, order); | |
orderPurchaseRepository.save(order); | |
})) | |
.subscribeOn(jdbcScheduler) | |
.subscribe(); | |
} | |
private void setStatus(TransactionEvent transactionEvent, OrderPurchase order) { | |
order.setStatus(SUCCESSFUL.equals(transactionEvent.getStatus()) | |
? COMPLETED | |
: FAILED); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment