Apache Pekko Persistence with Java
This example illustrates event sourcing with Apache Pekko Persistence.
Study the source code of the ShoppingCart.scala. A few things to note:
- The actor is implemented with the
EventSourcedBehavior - It defines
Command,EventandState - Commands define
replyTo: ActorRefto send a confirmation when the event has been successfully persisted Stateis only updated in the event handlerwithRetentionto enable snapshottingonPersistFailuredefines restarts with backoff in case of failures
Tests are defined in ShoppingCartTest.java. To run the tests, enter:
mvn test
The ShoppingCart application is expanded further in the pekko-sample-cqrs-java sample. In that sample the events are tagged to be consumed by even processors to build other representations from the events, or publish the events to other services.
0.1.0*