sender inside a future

前端 未结 3 814
感情败类
感情败类 2020-11-27 20:07

I have an actor which on receiving a message, searches the filesystem for a file and returns the full path of the File.

To keep it asynchronous, I have done:

3条回答
  •  囚心锁ツ
    2020-11-27 20:43

    import akka.pattern.pipe
    

    Does the trick. Doing:

    val reply = sender
    future {
      val ans = searchAndCache(s)
      println("Input Request: "+s+" output:"+ans+" "+reply.path)
      ans
    } pipeTo reply
    

    replies back to the sender

提交回复
热议问题