Recover Element from ActorFlow.ask() AskTimeoutException


I am wondering what the best way is to get hold of the element which caused the AskTimeoutExcpetion in a flow like this one so that I can send the “faulty” element to a special Flow/Sink.

Flow.<>create().via(ActorFlow.ask(1, rateProvider, askTimeout, RateRequest::new))

I can’t think of a way to access that while still using ActorFlow.ask, with mapAsync you could close over the element you use to do a regular actor ask and then use it to recover the future, it won’t be quite the same but the ability to tie the stream to the actor lifecycle you could achieve separately using .watch(ActorRef) .

1 Like