Concepts: Timers

Joe Hegarty edited this page Apr 26, 2016 · 1 revision


Timers in Orbit allow a programmer to run a task at set intervals. They are intended to be used for events which fire frequently (milliseconds, seconds).

Timers do not keep an actor activated and will disappear on deactivation.

Timers are usually registered during actor activation, although this is not a requirement.

Using Timers

Registration timer;
public Task activateAsync()
    timer = registerTimer(() -> printMessage(), 5, 5, TimeUnit.SECONDS);
    return super.activateAsync();
public Task printMessage()
    System.out.println("Timer Fired");
    timer = null; 
    return Task.done();
  • Registering a timer simply requires calling registerTimer
  • You can store the timer in a Registration object if required
  • Calling dispose on a timer will stop the timer from ticking.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.