learning scala akka tell pattern(二)
package com.example import akka.actor._ object Tutorial_02_Tell_Pattern extends App { println("Step 1: Create an actory system") val system = ActorSystem("DonutStoreActorSystem") val donutInActor = system.actorOf(Props[DonutInActor], name = "DonutInfoActor") import DonutStoreProtocal._ donutInActor ! Info("panzidong running!") val isTerminated = system.terminate() object DonutStoreProtocal { case class Info(name: String) } class DonutInActor extends Actor with ActorLogging{ import Tutorial_02_Tell_Pattern.DonutStoreProtocal._ override def receive: Receive = { case Info(name) =>{ log.info(s"Found $name dount") } } } }
result:
Step 1: Create an actory system [INFO] [08/23/2019 16:14:12.079] [DonutStoreActorSystem-akka.actor.default-dispatcher-3] [akka://DonutStoreActorSystem/user/DonutInfoActor] Found panzidong running! dount