com.yang_bo.dsl.keywords.akka.actor
A keyword to receive next message of an Akka actor.
A keyword to receive next message of an Akka actor.
杨博 (Yang Bo)
This ReceiveMessage.Partial keyword can be used in the akka.actor.Actor.Receive domain, to receive the next message that is a Message. The above code creates an actor to echo any string messages.
import akka.actor._ def echoActor = new Actor { def receive: Receive = { while (true) { val lastMessage = !ReceiveMessage.Partial[String] sender() ! lastMessage } throw new Exception("Unreachable code!") } } val pinger = system.actorOf(Props(echoActor)) pinger ! "hello world" expectMsg("hello world")
All messages that are not the class of Message will not be handled.
object UnhandledMessage pinger ! UnhandledMessage pinger ! "string message" expectMsg("string message")
domains.akka.actor.typed.typedReceiveMessage.PartialDsl for usage in the typed actor domains.