How it works...
In this recipe, we covered how to use the persistence layer of Lagom. We have mentioned that Lagom uses event sourcing and CQRS to implement persistence instead of a traditional approach, such as CRUD. In this particular example, we have a trip service that is able to start, collect locations, and end a trip. In order to make this service persistent, we need to define our persistent entities. We define ClientEntity for this purpose. ClientEntity extends from PersistentEntity, which forces us to implement a few things: the type of command, the type of event, the type of state, the initial state, and the behavior. Commands represent actions sent to this entity. In our case, we have three commands: StartTrip, EndTrip, and AddLocation ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access