For this recipe, we need to perform the following steps:
- Let's start with the reaper actor. This actor registers actorRefs from other actors and holds it in a set. Create a file named Reaper.scala inside package com.packt.chapter10. The code should look like this:
package com.packt.chapter10 import akka.actor.{Actor, ActorLogging, ActorRef, Terminated} import scala.collection.mutable object Reaper { case class WatchMe(ref: ActorRef) } class Reaper extends Actor with ActorLogging { import Reaper._ val watched = mutable.Set.empty[ActorRef] def allActorsTerminated() = { log.info("All actors terminated. Proceeding to shutdown system.") context.system.terminate() } def receive = { case WatchMe(ref) => log.info(s"Registering ...