This example is based on Lightbend CQRS-SAMPLE
This example contains a sample illustrating an CQRS design with Akka Cluster Sharding, Akka Cluster Singleton, Akka Persistence and Akka Persistence Query.
This sample application implements a CQRS-ES design that will side-effect in the read model on selected events persisted to google cloud datastore by the write model. In this sample, the side-effect is logging a line. A more practical example would be to send a message to a Kafka topic or update a relational database.
The write model is a shopping cart.
The implementation is based on a sharded actor: each ShoppingCart
is an Akka Cluster Sharding entity. The entity actor ShoppingCart
is an EventSourcedBehavior.
Events from the shopping carts are tagged and consumed by the read model.
The read model is implemented in such a way that 'load' is sharded over a number of processors. This number is event-processor.parallelism
.
The implementation is resilient: it uses an Akka Cluster Singleton in combination with Akka Cluster Sharding to always keep the event processors alive.