Hi Greg,

On Tue, Jul 1, 2014 at 8:38 PM, tigerfoot <gzol...@gmail.com> wrote:

> Hello,
>
> I have a job that's scheduled with Scheduler and I save the Cancellable.
>  The job isn't important, but it just sends a message to an Actor.
> After scheduling, it runs for a while and at some point I call cancel() on
> the Cancellable and need to ensure the job is actually done and won't fire
> again before continuing.
>
> What I'm finding is that cancel() on the Cancellable returns immediately
> and even looping/pausing on isCancelled doesn't ensure the job won't
> fire a few more times before finally stopping.  (It runs once a second for
> my test purposes.)
>
> Is there a way I can ensure my cancelled job is completely done, never to
> fire again, before proceeding?
>
> (Nothing special, but code that schedules the job below):
>
> scheduledServices.put(
> svc.serviceId,
> server.system.scheduler.schedule( 5 seconds, 5 seconds, myActor,
> ExecuteTest(svc) )
> )
>
>
If I understand your description correctly you schedule a message to be
sent to an actor. What you might see is that a few such messages have
already been sent when you call cancel, and they are queued in the mailbox
of the actor, and will eventually be received by the actor.

Would it be possible that the actor scheduled messages to itself instead?
Then you can easier check when receiving the scheduled message if is is
supposed to be processed or not.

Somewhat related section in the documentation:
http://doc.akka.io/docs/akka/2.3.4/scala/howto.html#scheduling-periodic-messages

Regards,
Patrik


> Thanks,
> Greg
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to