February 2018
Intermediate to advanced
552 pages
13h 46m
English
Our next step is to provide the implementation for another important and mandatory function of the PersistentActor trait—persistenceId. It is defined with the following signature:
def persistenceId: String
It should provide a unique ID for our persistent entity or Actor for which messages should be replayed. It is useful to provide our entity events in the journal uniquely.
Finally, our Persistence Actor looks like this:
class HelloWorldActor extends PersistentActor{
// Actor State
val entity: HelloWorldEntity = ....
def receiveRecover: Receive = {
// Implementation to recover the state of HelloWorldEntity from Journal } def receiveCommand: Receive = { // Implementation to Validate and Store ...Read now
Unlock full access