顶级Actor
import akka.actor.{ActorSystem, DeadLetter} |
- 创建顶级actor
demoActor
- 订阅deadLetter
- 发送消息 88
- 停止 demoActor下的myActor
demoActor
import akka.actor.{Actor, ActorIdentity, ActorLogging, DeadLetter, Identify, Props, Terminated} |
- 创建子Actor
myActor
- 用actorSelection 以路径才获得actorRef
- watch 用来监听 myActor的
Terminated
事件 context.stop(myActor)
停止子actor
myActor
class MyActor extends Actor { |
- override actor生命周期
- 获取事件并打印
Output
Hello, world! |
- 可以看到actor的启动和stop过程
- 用路径获取actorRef成功
- 死信消息拿到