How it works...
In this recipe, we covered how to integrate persistence into the FSM Akka module. To achieve this, first, we need to define our classes for the FSM: states, data, commands, and events. States are the different states in which your FSM can be at a given time. In our case, these states are Open and Close. Both extend CountDownLatchState, which is the type we provide to PersistentFSM in our actor. Data represents some additional information in the current state of your FSM. In our case, we are using Count to know how many operations left until the latch is done. Commands represent messages you send to your FSM actor. In our case, we only have two: Initialize and Mark. The Initialize message starts the countdown latch with a given ...
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