what's the difference between Supervision.Restart
and Supervision.Resume
really ?
Here is the situation. I have 3 elements coming from the Source(List(1, 2, 3))
. In runForeach
I throw exception if element is 2
. For Supervision.Restart
I expected only 1
to be processed. But oddly I see 3
reaching sink. Why ? I'm using Akka 2.4.11
import akka.actor.{ActorRef, ActorSystem}
import akka.stream.{ActorMaterializer, ActorMaterializerSettings, OverflowStrategy, Supervision}
import akka.stream.scaladsl.Source
val decider: Supervision.Decider = {
case _: NotImplementedError =>
Supervision.Restart
case _ =>
Supervision.Stop
}
implicit val system = ActorSystem("root")
implicit val executor = system.dispatcher
implicit val materializer = ActorMaterializer(ActorMaterializerSettings(system).withSupervisionStrategy(decider))(system)
Source(List(1, 2, 3))
.map { v =>
if (v == 2)
throw new NotImplementedError
v
}
.runForeach(println)
https://scalafiddle.io/sf/HSj01pO/3