IMHO the key is to minimise the potential for closing over state that isn't available to a future's callback. This is tricky, and the approach I'm going to suggest only diminishes the risk, it does not eliminate it.
I see that there are broadly two options: either create a worker actor to manage your asynchronous action; or use pipeTo as Michael suggests. Using a worker actor in place of the future isn't always under your control given that the future is yielded by some other library; as appears to be the case for you. Which leaves you pipeTo... The thing to manage it transforming the result of the future into a form that your actor can receive and continue with i.e. you may need to pass context. It is this additional context that you must be careful about constructing in order to avoid closing over state that isn't available to your callback. However given that you're just performing a transformation, the risk of closing over something is lessened. Here is an example (absolutely not tested/compiled/styled etc.): case UpdateState => { val tran = rClient.transaction() (tran.zcard(key) mapTo (z => (tran, key, z)) recover {case f => log.warning("ZCARD future failed ...", f)} pipeTo self) tran.exec() case (tran: Transaction, key: String, z: Int) => (tran.zrange(key, z - 1, z) recover {case e => log.warning("ZRANGE future failed ...", e)} pipeTo self) case x: ByteString => val v = x.utf8String log.info(s"Updating state with $v ") mutableState ++ v -- >>>>>>>>>> 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.