Package

com.yang_bo.dsl.keywords.akka

actor

Permalink

package actor

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.

    Installation

    This ReceiveMessage keyword supports !-notation, which requires BangNotation and ResetEverywhere compiler plugins along with this receivemessage library. For sbt, add the following settings to your build.sbt:

    addCompilerPlugin("com.thoughtworks.dsl" %% "compilerplugins-bangnotation" % "latest.release")
    addCompilerPlugin("com.thoughtworks.dsl" %% "compilerplugins-reseteverywhere" % "latest.release")
    libraryDependencies += "com.yang-bo.dsl.keywords.akka.actor" %% "receivemessage" % "latest.release"
    

    Author:

    杨博 (Yang Bo)

    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 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")
    See also

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

Value Members

  1. object ReceiveMessage extends Serializable

    Permalink

Ungrouped