We have looked at how it is safe to store state in an Actor—how Actors give us a lock-free way to deal with state in concurrency. We're going to look at how an actor can change its behavior in the face of different states now.

There are a few mechanisms you can use to change behavior in an actor:

  • Conditionals based on an Actor's state
  • Hotswap: become() and unbecome()
  • Finite State Machine (FSM)

We'll look at each after introducing the example that builds on our key-value datastore example.

Online/Offline state

Let's revisit the first fallacy of distributed computing. Not only is the network not reliable, but the components that we try to talk to over the network could be down. We want our application to handle network misses gracefully without dropping ...

Get Learning Akka now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.