Hi
I am trying to recover error using Supervision stategy, and it works
properly when I write Flow stages using map, but if I use graph stage, it
is never caught, and the entire pipeline fails
Here is sample code to replicate the scenario (It will always fail)
object test extends App{
val stageSupervisionDecider: Supervision.Decider = {
case cEx: IllegalArgumentException =>
println("Supervision Catch")
Supervision.Resume
case _ => Supervision.Stop
}
implicit val system = ActorSystem("system")
implicit val materializer = ActorMaterializer(
ActorMaterializerSettings(system)
.withSupervisionStrategy(stageSupervisionDecider)
)
Source(Vector(1,2,3,4,5,6,7))
.via(new FailFlow)
.runWith(Sink.foreach(println))
}
class FailFlow extends GraphStage[FlowShape[Int, Int]] {
val in = Inlet[Int]("FailFlow.In")
val out = Outlet[Int]("FailFlow.Out")
override def initialAttributes: Attributes =
ActorAttributes.supervisionStrategy(test.stageSupervisionDecider)
override def shape: FlowShape[Int, Int] = FlowShape.of(in, out)
override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = {
new GraphStageLogic(shape) {
setHandler(in, new InHandler {
override def onPush(): Unit = {
val m = grab(in)
if(m % 2 == 0)
throw new IllegalArgumentException("illegal value")
else
push(out,m)
}
})
setHandler(out, new OutHandler {
override def onPull(): Unit = {
pull(in)
}
})
}
}
}
Any Ideas what is going wrong here?
Regards
Kinshuk Bairagi
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.