Akka文檔說明不掃描郵箱中的郵件。每個消息按照它們到達的順序依次處理(默認爲FIFO)。然而,當我從一個演員發送一個消息到另一個不匹配的接收演員時,它既不會被移動到deadletters actor(它會出現在日誌中,我想),也不會阻止處理郵箱中的下一條消息一秒鐘後到達,可以正確處理。使用Akka會發生什麼不匹配的消息?
發生來自郵箱的不匹配郵件會發生什麼情況?
我在sbt中使用了Scala 2.10.4和Akka 2.4-SNAPSHOT。
package main.scala
import akka.actor._
class SRActor(dest: ActorRef) extends Actor with ActorLogging {
dest ! A
dest ! B
context.stop(self)
override def receive = {
case _ => {
log.info("Finally got something")
}
}
}
class SRActorReceiver extends Actor with ActorLogging {
override def receive = {
case B =>
log.info("Finally got B")
}
}
演員創作:
package main.scala
import akka.actor._
case object A
case object B
object ErrorApp extends App {
// SR: Send nowhere received
var system6 = ActorSystem("ErrorActorSystem")
val srActorReceiver = system6.actorOf(Props(classOf[SRActorReceiver]), "sractorreceiver")
val sractor = system6.actorOf(Props(classOf[SRActor], srActorReceiver), "sractor")
// wait until actors have finished
Thread.sleep(1000)
system6.shutdown