I have to pass supervision.decider
but in akka 2.6.0+ Materializer
does not have similar settings.
Can anyone share how to write below code in higher version:
val mat: ActorMaterializer = ActorMaterializer(Actor Materializersettings(supervision.decider))
Tried new way, not picking as strategy class requires String
:
1.
val mat: Materializer = Matrializer(actorsystem)
mat.system.settings.supervisionstratgyclass = ???
ActorAttributes(supervision.decider)
Any idea would be appreciated how to pass supervision strategy through materializer.
How we pass custom supervision strategy in settings? I don't use streams. It will simple startup call with materializer.
Sounds like you want to setup a supervision strategy for a stream. Here you have some examples of how to do it from the official documentation: Stream error - supervision strategies.
As you can see, in the following example a default supervision strategy is being set for the runnable graph
val decider: Supervision.Decider = {
case _: ArithmeticException => Supervision.Resume
case _ => Supervision.Stop
}
val source = Source(0 to 5).map(100 / _)
val runnableGraph =
source.toMat(Sink.fold(0)(_ + _))(Keep.right)
val withCustomSupervision = runnableGraph.withAttributes(ActorAttributes.supervisionStrategy(decider))
In this other one, a supervision strategy is being defined at Flow
level
val decider: Supervision.Decider = {
case _: ArithmeticException => Supervision.Resume
case _ => Supervision.Stop
}
val flow = Flow[Int]
.filter(100 / _ < 50)
.map(elem => 100 / (5 - elem))
.withAttributes(ActorAttributes.supervisionStrategy(decider))
val source = Source(0 to 5).via(flow)