Chapter 6. Actors

 

This chapter covers

  • Creating actors and actor hierarchies
  • Sending messages and handling failure the Akka way
  • Reacting to load with control messages and circuit breakers

The actor-based concurrency model[1] was popularized by the Erlang programming language and is implemented on the JVM by the Akka concurrency toolkit (http://akka.io). This chapter provides an introduction to the wonderful world of actors. As you’ll see, actors are a very effective tool for building scalable and resilient applications. As Akka is available out of the box in Play, we can use it to implement more-advanced asynchronous logic.

1Carl Hewitt, Peter Bishop, and Richard Steiger, “A universal modular ACTOR formalism for artificial intelligence,” in Proceedings of the 3rd international joint conference on artificial intelligence IJCAI’73 (Morgan Kaufmann Publishers, 1973), 235-245.

Actors are a vast topic, and we’ll only look at the most important aspects to get started using them. If you want to get a deeper understanding of actors, I recommend looking at Akka’s excellent documentation (http://akka.io/docs) as well as at a book dedicated to the topic, such as Kuhn and Allen’s Reactive Design Patterns (Manning, 2016) or Akka in Action by Roestenburg, Bakker, and Williams (Manning, 2016).

6.1. Actor fundamentals

6.2. Letting it crash—supervision and recovery

6.3. Reacting to load patterns for monitoring and preventing service overload

6.4. Summary