Hello, Beginner here, I'm experiencing some issues with a particular portion of my code :
val paths = ListBuffer.empty[List[File]] futureFiles.foreach{ _.onComplete{ case Success(list: List[File]) => paths += list case Failure(ex) => log.info("Retrieval of files failed : {}", ex.getLocalizedMessage) } } sender() ! Detected(paths.flatten.toIndexedSeq) futureFiles is a List[Future[List[File]]]. So I attach a callback on each of them and construct a new list from it. My problem is because this is asynchronous code, sometimes it will make the tell before the paths list is filled up, thus sending nothing. I figured I'd try something like this : Future.sequence(futureFiles).onComplete{ case Success(lists) => sender() ! Detected(lists.flatten.toIndexedSeq) case Failure(ex) => log.info("Retrieval of files failed : {}", ex.getLocalizedMessage) } But doing so I lose some failure messages because of the sequencing, and it doesn't work anyway because the message is going straight to dead letters. So how can I achieve this ? Thanks -- >>>>>>>>>> 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+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.