官术网_书友最值得收藏!

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")
}
主站蜘蛛池模板: 临湘市| 会昌县| 苍溪县| 新津县| 凤台县| 大洼县| 鄂伦春自治旗| 浦县| 赣州市| 玉树县| 西平县| 乡宁县| 凯里市| 河津市| 鹿邑县| 临清市| 石阡县| 繁峙县| 宜都市| 柞水县| 三都| 根河市| 华安县| 全椒县| 延寿县| 抚松县| 金溪县| 河南省| 东方市| 孟津县| 广河县| 玉溪市| 革吉县| 龙海市| 沁水县| 延边| 麻栗坡县| 丹巴县| 资兴市| 永嘉县| 西青区|