Abhishek Batra
Abhishek Batra

Reputation: 1599

Akka Stream: Flow Stage is interrupted without any error

I have a akka stream of type

  source
    .filter( // Filtering logic)
    .map(// Mainly used for logging)
    .async
    .map(cmd => { log.info("Some more logging here"); cmd}
    .via(flow)
    .async
    .runWith(sink)

I am facing a strange issue. My flow stage is a long time-consuming flow. For some of the elements, it is partially executed. I see no errors of any type. It seems like the thread is suddenly dropped while it is in execution. This code runs on production servers, and I am observing about 150 elements in the stream is partially processed.

I am very new to Scala and Akka, apologize if I have used any wrong terminology describing my problem statement.

Upvotes: 0

Views: 86

Answers (1)

Ivan Stanislavciuc
Ivan Stanislavciuc

Reputation: 7275

Add more logging with a Supervision strategy when creating a materializer. This will log all errors and keep the flow running. By default, flow stops on first exception.

private val decider: Supervision.Decider = { ex =>
  logger.error(ex.getMessage, ex)
  Supervision.Resume
}

private implicit val materializer: ActorMaterializer = ActorMaterializer(
  ActorMaterializerSettings(system).withSupervisionStrategy(decider)
)

Upvotes: 1

Related Questions