我在lagom
下面有一个主题订阅者
fooService.fooTopic().subscribe
.atLeastOnce(
Flow[fooMsg].map {
case fooMsg(_) =>
foo()
case a =>
println(a)
}.async.map{ _ =>
Done
}
)
订阅这个主题,我使用atLeastOnce
作为方法,所以如果有任何异常,我希望流程重新启动/重试。当我抛出一个正常的异常时,它可以继续正常重试
private def foo() = {
throw new RuntimeException("testing error")
}
但是当将来发生异常时,无论我如何尝试,Flow都不会重新启动。这是我将来处理异常的尝试之一
private def foo() = {
val test: Future[Int] = Future(throw new RuntimeException("asd"))
val result = for {
y1 <- test
} yield (y1)
result.onComplete{
case Success(value) => println("SUCCESS")
case Failure(exception) => println(exception.getMessage)
throw exception
}
}
private def foo() = {
val test: Future[Int] = Future(throw new RuntimeException("asd"))
test.onComplete{
case Success(value) => println("SUCCESS")
case Failure(exception) => println(exception.getMessage)
throw exception
}
}
它会显示一个异常,但Flow
不会自动重新启动它。我应该如何处理/抛出异常Future
?