January 2018
Intermediate to advanced
470 pages
11h 9m
English
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")}
Read now
Unlock full access