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

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")
}
主站蜘蛛池模板: 城口县| 杂多县| 贡山| 屯留县| 阳谷县| 泗洪县| 垫江县| 津南区| 白沙| 佛冈县| 阿尔山市| 竹溪县| 东莞市| 银川市| 乌审旗| 富源县| 永昌县| 东乡| 永仁县| 丹江口市| 仙桃市| 高雄县| 肥乡县| 南靖县| 阿巴嘎旗| 读书| 陇川县| 渭源县| 西林县| 博乐市| 余江县| 太康县| 清镇市| 博白县| 财经| 满城县| 仪陇县| 乳源| 伊金霍洛旗| 通渭县| 囊谦县|