February 2018
Intermediate to advanced
552 pages
13h 46m
English
The next step is that we need to provide implementation for another important and mandatory function (or method) of the PersistentActor trait—receiveCommand. It is defined with the following signature:
def receiveCommand: Receive
It is also known as command handler. It receives commands and validates them. If those commands are valid, then it generates one or more events and runs a persist function to persist those events to the journal or data store. Then it updates the state of the PersistentActor.
As we discussed in the previous section, the Akka Persistence module first persists the generated event to the journal, and only then updates.
If the persisting of the events steps fail, it ...
Read now
Unlock full access