I have a topic subscriber in lagom
as bellow
fooService.fooTopic().subscribe
.atLeastOnce(
Flow[fooMsg].map {
case fooMsg(_) =>
foo()
case a =>
println(a)
}.async.map{ _ =>
Done
}
)
to subscribe this topic, im using atLeastOnce
as the method, so that if theres any exception, I want the flow to be restarted/retried. when im throwing a normal exception, it could keep retrying normally
private def foo() = {
throw new RuntimeException("testing error")
}
but when the exception happens in the future, no matter how I tried it, the Flow wont restart. heres one of my tries to handle the exception in the future
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
}
}
it will show an exception, but the Flow
wont restart it automatically. How should I handle/throw the exception in the Future
?