Akka笔记(tell 和 ask)
Actor发送消息分Tell和Ask两种
?
Tell 发送不返回结果
ActionRef ! "hello"
?
Ask 发送需要等待结果,需要设置超时时间
?
implicit val timeout = Timeout(5 seconds) println(new Date()) val future = f ? "hello" try{ //Future Await时间设置,哪个更小,就等待最小时间,这个例子就是最多等待5秒 val re = Await.result(future,10 seconds) println("hexin:"+re) }catch{ case e:Exception => println(new Date()) }?