How to do it...

For this recipe, we need to perform the following steps:

  1. Let's start with the worker actors. These actors are the children that you want to terminate in order. Create a file named ServiceHandler.scala inside package com.packt.chapter10 with the following content:
        package com.packt.chapter10        import akka.actor.{Actor, ActorLogging}        class ServiceHandler extends Actor with ActorLogging {          def receive = Actor.ignoringBehavior          override def preStart() = log.info(s"${self.path.name} is             running")          override def postStop() = log.info(s"${self.path.name} has              stopped")        }
  1. Second, let's create the ServicesManager actor. This actor will act as the parent of the workers but it will receive the children from the real actor parent. Create ...

Get Akka Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.