Akka流-计时器或计划程序(如CRON) [英] Akka Stream - Timer or Scheduler like CRON
本文介绍了Akka流-计时器或计划程序(如CRON)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Scala上使用Akka Stream。 我想设置一个调度程序,该调度程序每24:00运行一次。我试图寻找它。但是我找不到我想做的事。您能告诉我如何编写代码吗?
I use Akka Stream on Scala. I'd like to set a scheduler which runs on every 24:00. I tried to search for it. But I could't find what I want to do. Could you tell me how to write code?
推荐答案
使用Akka调度程序中的构建,请参见:
http://doc.akka.io/docs/akka/current/scala/scheduler。 html
Use the build in Akka scheduler, see: http://doc.akka.io/docs/akka/current/scala/scheduler.html
您可以使用调度程序,例如:
You can use the scheduler like:
system.scheduler.schedule(
initialDelay = FiniteDuration(/*offset to next 24:00*/),
interval = FiniteDuration(24, TimeUnit.HOURS),
receiver = self,
message = ScheduleAkkaStream
)
然后在演员中,当ScheduleAkkaStream为收到,执行任务
Then in the actor, when the ScheduleAkkaStream is received, run the job
这篇关于Akka流-计时器或计划程序(如CRON)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文