Error Kernel example in Actor docs doesn't do what is intended
http://akka.io/docs/akka/2.0-M4/scala/actors.html#id8
The spirit of this code is the error kernel pattern. It looks like you're trying to do
OriginalSender -> Actor -> AnonymousActor -> Actor -> OriginalSender
But, the OriginalSender is lost. It will do this instead:
OriginalSender -> Actor -> AnonymousActor -> Actor -> DeadLetter (due to the fact that AnonymousActor shut itself down)
The spirit of this code is the error kernel pattern. It looks like you're trying to do
OriginalSender -> Actor -> AnonymousActor -> Actor -> OriginalSender
But, the OriginalSender is lost. It will do this instead:
OriginalSender -> Actor -> AnonymousActor -> Actor -> DeadLetter (due to the fact that AnonymousActor shut itself down)
def receive = {
case m: DoIt ⇒
context.actorOf(Props(new Actor {
def receive = {
case DoIt(msg) ⇒
val replyMsg = doSomeDangerousWork(msg)
sender ! replyMsg
context.stop(self)
}
def doSomeDangerousWork(msg: ImmutableMessage): String = { "done" }
})) ! m
// HERE: Sender is the stopped child (or at least the soon-to-be-stopped child)
case replyMsg: String ⇒ sender ! replyMsg
}
Leave a comment
on 2012-02-08 09:45 *
By Patrik Nordwall
Assigned to set to Patrik Nordwall
Status changed from New to Accepted
on 2012-02-08 10:05 *
By Patrik Nordwall
(In revision:b25d25e6f730e725f03c534a787f6b5fef997ba1) DOC: Error Kernel example in Actor docs doesn't do what is intended. See #1803
Branch: master
Branch: master
Thanks for reporting. Changed to forward so that the reply is sent directly to the original sender.