In this chapter, we supplemented our event sourced entity model with a separate read model, following the CQRS pattern. We implemented our separate read models by leveraging Akka's Persistence Query feature to listen to event streams from our entities and project those events into Elasticsearch, which serves as our read model data store. Following this approach gives us rich query capabilities against the current state of our entities while still preserving the event sourced nature of those entities for the write model. We also leveraged Persistence Query to finalize the back-and-forth interaction between the inventory and sales modules when allocating an inventory to a new sales order.
The code we created in this chapter to listen to the event stream was a good starting point, but we really didn't leverage some of the cool features from Akka Streams, such as proper back-pressure handling. We'll plunge right into this in the next chapter, when we introduce Akka Streams as a mechanism...