Akka 调度程序在异常时停止;是预期的吗?
Akka scheduler stops on exception; is it expected?
我们运行这段代码:
scheduler.schedule(1 minute, 1 minute) { triggerOperations.tick() }
启动我们的应用程序时,调度程序是 Akka actorSystem.scheduler。
如果 tick() 抛出异常,则永远不会再调用它!
我检查了文档,但找不到任何关于这是预期的声明。大多数描述是 "Schedules a function to be run repeatedly with an initial delay and a frequency",没有提到如果函数抛出异常,任务将停止触发。
我们的akka版本是2.3.2。
http://doc.akka.io/docs/akka/2.3.4/scala/scheduler.html
http://doc.akka.io/api/akka/2.0/akka/actor/Scheduler.html
这种行为是预期的吗?是否在任何地方记录?
如有疑问,请查看源代码。代码有点简洁,但是this fragment:
override def run(): Unit = {
try {
runnable.run()
val driftNanos = clock() - getAndAdd(delay.toNanos)
if (self.get != null)
swap(schedule(executor, this, Duration.fromNanos(Math.max(delay.toNanos - driftNanos, 1))))
} catch {
case _: SchedulerException ⇒ // ignore failure to enqueue or terminated target actor
}
}
表明,如果您的可运行对象抛出异常,调度程序不会重新安排下一次执行(据我所知,这发生在交换内部)。
我们运行这段代码:
scheduler.schedule(1 minute, 1 minute) { triggerOperations.tick() }
启动我们的应用程序时,调度程序是 Akka actorSystem.scheduler。 如果 tick() 抛出异常,则永远不会再调用它!
我检查了文档,但找不到任何关于这是预期的声明。大多数描述是 "Schedules a function to be run repeatedly with an initial delay and a frequency",没有提到如果函数抛出异常,任务将停止触发。
我们的akka版本是2.3.2。
http://doc.akka.io/docs/akka/2.3.4/scala/scheduler.html http://doc.akka.io/api/akka/2.0/akka/actor/Scheduler.html
这种行为是预期的吗?是否在任何地方记录?
如有疑问,请查看源代码。代码有点简洁,但是this fragment:
override def run(): Unit = {
try {
runnable.run()
val driftNanos = clock() - getAndAdd(delay.toNanos)
if (self.get != null)
swap(schedule(executor, this, Duration.fromNanos(Math.max(delay.toNanos - driftNanos, 1))))
} catch {
case _: SchedulerException ⇒ // ignore failure to enqueue or terminated target actor
}
}
表明,如果您的可运行对象抛出异常,调度程序不会重新安排下一次执行(据我所知,这发生在交换内部)。