Package

com.yang_bo.dsl.keywords.akka

actor

Permalink

package actor

Contains keyword for Akka actors.

Author:

杨博 (Yang Bo)

Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. actor
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final case class ReceiveMessage[Message]() extends Keyword[ReceiveMessage[Message], Message] with Product with Serializable

    Permalink

    A keyword to receive next message of an Akka actor.

    A keyword to receive next message of an Akka actor.

    Message

    The type of message being received, which must be Any for akka.actor.Actor, and must be the same type of T for akka.actor.typed.Behavior.

    Example:
    1. This ReceiveMessage keyword can be used in the akka.actor.Actor.Receive domain, to receive the next message. The above code creates an actor to echo any messages.

      import com.yang_bo.dsl.keywords.akka.actor.ReceiveMessage
      import akka.actor._
      def echoActor = new Actor {
        def receive: Receive = {
          while (true) {
            val lastMessage = !ReceiveMessage[Any]
            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.

      pinger ! "string message"
      expectMsg("string message")
    See also

    domains.akka.actor.typed.typedReceiveMessageDsl for usage in the typed actor domains.

  2. final case class ReceiveMessagePartial[Message]() extends Keyword[ReceiveMessagePartial[Message], Message] with Product with Serializable

    Permalink

    A keyword to receive next message of an Akka actor.

    A keyword to receive next message of an Akka actor.

    Author:

    杨博 (Yang Bo)

    Example:
    1. This ReceiveMessagePartial 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 com.yang_bo.dsl.keywords.akka.actor.ReceiveMessagePartial
      import akka.actor._
      def echoActor = new Actor {
        def receive: Receive = {
          while (true) {
            val lastMessage = !ReceiveMessagePartial[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")
    See also

    domains.akka.actor.typed.typedReceiveMessagePartialDsl for usage in the typed actor domains.

Value Members

  1. object ReceiveMessage extends Serializable

    Permalink
  2. object ReceiveMessagePartial extends Serializable

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped