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

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")
}
主站蜘蛛池模板: 合阳县| 茌平县| 茌平县| 济宁市| 永泰县| 美姑县| 石河子市| 元氏县| 三亚市| 铜陵市| 天峻县| 徐汇区| 双鸭山市| 屏东县| 博兴县| 西林县| 斗六市| 东海县| 长岛县| 永靖县| 友谊县| 依兰县| 福鼎市| 饶平县| 县级市| 墨竹工卡县| 云南省| 庆阳市| 元谋县| 含山县| 滨州市| 北安市| 新竹县| 镇原县| 田阳县| 云和县| 年辖:市辖区| 怀来县| 前郭尔| 新津县| 黄浦区|