Akka queue stream recover and drop element back in top

313 views
Skip to first unread message

scal...@twitter.com

unread,
Apr 9, 2017, 7:25:40 AM4/9/17
to Akka User List
Hey all,

In my example below I have a source queue. In the middle I have a flow that can fail for a few different network related reason and all I want to do is drop the request back in the top of the funnel. But I am not entirely sure how I can get access to the element that went into the flow and caused the failure.

val queue = Source.queue[ArchiveValidationRequest](50, OverflowStrategy.fail)
queue.via(alwaysOnFlow).recover {
  case ex: Throwable =>
    error("Element failed. Reinserting back into queue to be processed")
    queue.offer(???)       
}

This seems like a fairly basic pattern but its not super obvious how to get that failed request. recoverWithRetries doesn't seem to be what I want here as I just want to capture the failed element and just try to process it later.

Akka Team

unread,
Apr 25, 2017, 7:54:49 AM4/25/17
to Akka User List
Recover will catch an exception coming from upstream and continue by emitting a single element before completing. Indeed does not sound like what you are after. 

Maybe the retry stream in akka-stream-contrib could give you some inspiration on how to solve your problem: https://github.com/akka/akka-stream-contrib/blob/master/contrib/src/main/scala/akka/stream/contrib/Retry.scala

--
Johan 
Akka Team

--
>>>>>>>>>> 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 akka-user+unsubscribe@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages