--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/hVdDFyLBrv0J.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
Alex--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/hVdDFyLBrv0J.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
Hi Alex,On Thu, May 10, 2012 at 4:44 PM, Alex <bertra...@gmail.com> wrote:Hi,I have some worker actors, which do some work. When they finish their work they should stop. No problem so far. But I have an additional requirement. The worker should also stop if it hasn't finish the work after defined duration.My current approach is to stop the worker in 2 places:def preStart() {context.system.scheduler.scheduleOnce(...) { context.stop(self) }}
def receive = {case ... =>... // do somethingcontext.stop(self)}I get an "[TaskInvocation] null" error. I suppose if a worker finishes its work early enough, self becomes null and the scheduled function fails.Is the approach ok? How to avoid the described error?Just as Derek says, you're closing over context and publish it to another thread. This is not allowed.So you can either:system stop selforself ! PoisonPill
Cheers,√Alex--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/hVdDFyLBrv0J.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
--
Viktor Klang
Akka Tech Lead--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
On May 10, 2012, at 17:06 , √iktor Ҡlang wrote:Hi Alex,On Thu, May 10, 2012 at 4:44 PM, Alex <bertra...@gmail.com> wrote:
Hi,I have some worker actors, which do some work. When they finish their work they should stop. No problem so far. But I have an additional requirement. The worker should also stop if it hasn't finish the work after defined duration.My current approach is to stop the worker in 2 places:def preStart() {context.system.scheduler.scheduleOnce(...) { context.stop(self) }}
def receive = {case ... =>... // do somethingcontext.stop(self)}I get an "[TaskInvocation] null" error. I suppose if a worker finishes its work early enough, self becomes null and the scheduled function fails.Is the approach ok? How to avoid the described error?Just as Derek says, you're closing over context and publish it to another thread. This is not allowed.So you can either:system stop selforself ! PoisonPillBut as Derek—spot on—pointed out, this won’t solve the problem of trying to stop the actor while it keeps processing its message. It will get rid of the exception, though ;-)
To unsubscribe from this group, send email to akka-user+unsubscribe@googlegroups.com.