我正在寻找简单的Job Scheduler,可以在Scala中使用,可以在Mongo中存储作业,或者至少可以扩展为使用Mongo作为存储。
有人能提出最佳解决方案吗?
答案 0 :(得分:1)
可以使用Akka构建一个非常简单但可扩展的调度程序系统:
import akka.actor._ import akka.util.duration._ val system = ActorSystem("SchedulerTest") case object Job val runnerActor = system.actorOf(Props( new Actor{ def receive = { case Job => println("run " + self.path.name)} } )) //schedule a Job message to the actor in 500 ms system.scheduler.scheduleOnce(500 milliseconds, runnerActor, Job) //system.scheduler.schedule(0 milliseconds, 50 milliseconds, runnerActor, Job) //this repeats a message every 50 ms
工作者可以选择安排其他事件。 可以通过多种方式将配置序列化为db。