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

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")
}
主站蜘蛛池模板: 芜湖市| 邵阳县| 徐汇区| 杭锦后旗| 盐津县| 兴海县| 长丰县| 界首市| 福鼎市| 克山县| 上栗县| 常宁市| 会东县| 颍上县| 宣化县| 二手房| 右玉县| 呼伦贝尔市| 抚顺市| 赤峰市| 和平区| 宜良县| 靖西县| 红原县| 衡阳市| 双辽市| 陆川县| 中阳县| 文昌市| 长海县| 汨罗市| 西和县| 措勤县| 满洲里市| 蓝田县| 东至县| 余庆县| 两当县| 高阳县| 洞口县| 阳西县|