Scheduler

Scheduler takes the frequency constant from the application.conf and uses the Actor system to send an update message (the content does not matter; SchedulerActor reacts to any message) to SchedulerActor every X seconds:

class Scheduler @Inject()
(val system: ActorSystem, @Named("scheduler-actor") val schedulerActor: ActorRef, configuration: Configuration)(implicit ec: ExecutionContext) {
//constants.frequency is set in conf/application.conf file
val frequency = configuration.getInt("constants.frequency").get
var actor = system.scheduler.schedule(
0.microseconds, //initial delay: whether execution starts immediately after app launch
frequency.seconds, //every X seconds, specified above
schedulerActor,
"update")
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset