Exercises
The following exercises test your understanding of the actor programming model, and distributed programming in general. The first few exercises are straightforward, and deal with the basics of the actor API in Akka. Subsequent exercises are more involved, and go deeper into the territory of fault-tolerant distributed programming. Try to solve these exercises by first assuming that no machines fail, and then consider what happens if some of the machines fail during the execution of the program:
Implement the timer actor with the
TimerActorclass. After receiving aRegistermessage containing thettimeout in milliseconds, the timer actor sends aTimeoutmessage back aftertmilliseconds. The timer must accept multipleRegistermessages.Recall the bank account example from Chapter 2, Concurrency on the JVM and the Java Memory Model. Implement different bank accounts as separate actors, represented by the
AccountActorclass. When anAccountActorclass receives aSendmessage, it must...