AKKA Scheduler: Sending Message to Actor’s Self on StartAkka has a little scheduler written using actors. This can be convenient if you want to schedule some periodic task for maintenance or similar. It allows you to register a message that you want to be sent to a specific actor at a periodic interval.
How Does AKKA Schedule Things?
service.scheduleAtFixedRate( createSendRunnable( receiver, message, true ), initialDelay, delay, timeUnit).asInstanceOf[ScheduledFuture[AnyRef]]
“Heartbeat” would be an ideal example of such use case => “When a ‘Hearbeat Actor’ starts, it should start sending heartbeats with a given interval (e.g. every 2 seconds)”
Creating a Message
sealed trait HeartbeatMessage case object SendHeartbeat extends HeartbeatMessage
Read the full post at: AKKA Scheduler: Sending Message to Actor's Self on Start