My question is regarding communication between aggregate roots in event sourcing using Akka persistent actors. Specifically, if I want an aggregate root to respond to an event that happened in another aggregate root, how do I do that?
Using the shopping cart example: Implementing Microservices with Akka :: Akka Platform Guide, we can take the example that the Item aggregate needs to know when a cart has been checked out to update its count in the warehouse. What’s the most idiomatic way to do this? I can think of two options
- Have the Item actor representing the AR also understand the ShoppingCart.Event type (Behavior[Item.Command with ShoppingCart.Event]) and have it subscribe to a stream of events from the shopping cart service, or
- Have a a coordinator actor subscribe to a stream of events (requiring the producing aggregates to produce to it) and send commands to the correct aggregate roots
7 posts - 3 participants