This sample is an adaptation of
Dining Hakkers.
It illustrates how state and behavior can be managed within
an Actor with two different approaches; using become and using
the AbstractFSM class.
Open DiningHakkersOnBecome.java.
It illustrates how current behavior can be replaced with context.become.
Note that no var members are used, instead the state is encoded in the current
behavior and its parameters.
Go to the Run tab, and start the application main class
sample.become.DiningHakkersOnBecome.
In the log output you can see the actions of the Hakker actors.
Read more about become in
the documentation.
Open DiningHakkersOnFsm.java.
It illustrates how the states and transitions can be defined with the akka.actor.AbstractFSM class.
Go to the Run tab, and start the application main class
sample.fsm.DiningHakkersOnFsm.
In the log output you can see the actions of the Hakker actors.
Read more about akka.actor.FSM in
the documentation.