I am new to Akka / Scala and trying to debug the code below. When he resultSetParser
has an exception, he does not drop it. Instead, a service using this code is simply idle forever.
How can I make my service throw an exception and not just wait in a thread? Is there something like a function watchException()
in Akka that I could call right after watchTermination()
to make it throw an exception that it sees when processing the stream?
val chunkSource: Source[ChunkStreamPart, NotUsed] =
Source
.fromIterator(() => resultSetParser(resultSet) map ChunkStreamPart.apply)
.watchTermination()((mat : NotUsed, fut : Future[Done]) => {
watchTermination(fut)
mat
})
val chunkEntity = Chunked(ContentTypes.`application/json`, chunkSource)
source
share