I'm running an akka stream reading from Kafka and I want to commit messages back to Kafka when the file serialization succeeds. But I don't know how to notify upstream stages about a failure downstream.
Right now, I've created a GraphStage with FanOutShape2[ConsumerMessage.CommittableMessage[Array[Byte], Array[Byte]],
ConsumerRecord[Array[Byte], Array[Byte]],
ConsumerMessage.CommittableOffsetBatch]
.
I would like push to the offset commits outlet when the downstream sink finish consuming all the hourly grouped ConsumerRecords
, but I want to hold those commits when the File couldn't be properly finished.
So given this simplified scenarion, say that I have the following stream
Source(List("one", "two"))
.map(ByteString(_))
.runWith(FileIO.toPath(Paths.get("/file-in-root-will-fail.txt")))
that will end in a IOResult(0,Failure(java.nio.file.AccessDeniedException: /file-in-root-will-fail.txt))
.
How could I notify an upstream stage that this happened?