我读到了危险案例there。
现在,我正在开发一个应该跟踪传入消息的扩展。即当消息到达时,我必须通知某个外部系统该消息已到达。
在另一个actor中创建actor对象并将其传递给props工厂是否安全?
class HandlingActorWrapper(val decoratee: Actor) extends Actor {
override def receive: Receive = {
System.out.println("Message recieved");
decoratee.receive
}
}
object HandlingActorWrapper{
def props(actor: Actor) = Props(new HandlingActorWrapper(actor))
}
class MyActor extends Actor {
override def receive: Receive = {
//handling messages
}
}
class SomeActor extends Actor {
var child : ActorRef = _
override def preStart() = {
//>>|HERE
child = context.system.actorOf(HandlingActorWrapper.props(new MyActor))
}
//other
}