How it works...
In this recipe, we covered how to schedule messages within an actor system. Through the actor MessageAkkaScheduler, we can see how the actor system provides a built-in scheduler. This scheduler lets you schedule messages to be sent after a given duration through the scheduleOnce method or periodically with an initial delay using the method schedule. We can also see how the scheduler returns an instance of Cancellable. This allows you to cancel the delivery of messages in case your use case requires it. Another good point to mention is that the scheduler needs execution content in order to execute these tasks. We are importing context.dispatcher for this purpose. This allows the scheduler to use the same dispatcher as your ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access