Last active
May 25, 2022 08:54
-
-
Save danielsiwiec/11df70cea8b46984063d97fab590d136 to your computer and use it in GitHub Desktop.
Order Processing - Choreography - Order Service
This file contains 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
class OrderService(private val availableSkus:MutableList<Int> = mutableListOf()) { | |
fun submitOrder(order: Order) { | |
sendMessage( | |
ORDERS, | |
order.withStatus(if (availableSkus.containsAll(order.items)) SUBMITTED else ITEMS_UNAVAILABLE) | |
) | |
} | |
@KafkaListener(topics = [SKUS]) | |
fun onSku(sku: Sku) { | |
if (sku.onStock > 0) availableSkus.add(sku.id) else availableSkus.remove(sku.id) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment