2011-12-19 11:07:59 +01:00
|
|
|
/**
|
2012-01-19 18:21:06 +01:00
|
|
|
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
2011-12-19 11:07:59 +01:00
|
|
|
*/
|
2012-05-22 11:37:09 +02:00
|
|
|
package docs.actor
|
2011-12-06 16:49:39 +01:00
|
|
|
|
2012-06-28 15:33:49 +02:00
|
|
|
import language.postfixOps
|
|
|
|
|
|
2011-12-06 16:49:39 +01:00
|
|
|
//#imports1
|
|
|
|
|
import akka.actor.Actor
|
2011-12-13 14:09:40 +01:00
|
|
|
import akka.actor.Props
|
2011-12-06 16:49:39 +01:00
|
|
|
import akka.event.Logging
|
2011-12-11 20:12:55 +01:00
|
|
|
|
2011-12-06 16:49:39 +01:00
|
|
|
//#imports1
|
|
|
|
|
|
2012-07-04 15:25:30 +02:00
|
|
|
import scala.concurrent.Future
|
2012-02-06 12:18:08 +01:00
|
|
|
import akka.actor.{ ActorRef, ActorSystem }
|
2011-10-05 17:41:00 +02:00
|
|
|
import org.scalatest.{ BeforeAndAfterAll, WordSpec }
|
|
|
|
|
import org.scalatest.matchers.MustMatchers
|
|
|
|
|
import akka.testkit._
|
2011-12-14 14:05:44 +01:00
|
|
|
import akka.util._
|
2012-06-29 13:33:20 +02:00
|
|
|
import scala.concurrent.util.duration._
|
2011-12-20 08:12:20 +01:00
|
|
|
import akka.actor.Actor.Receive
|
2012-06-29 16:06:26 +02:00
|
|
|
import scala.concurrent.Await
|
2011-10-05 17:41:00 +02:00
|
|
|
|
|
|
|
|
//#my-actor
|
|
|
|
|
class MyActor extends Actor {
|
2011-12-05 20:01:42 +01:00
|
|
|
val log = Logging(context.system, this)
|
2011-10-05 17:41:00 +02:00
|
|
|
def receive = {
|
2011-10-27 12:23:01 +02:00
|
|
|
case "test" ⇒ log.info("received test")
|
|
|
|
|
case _ ⇒ log.info("received unknown message")
|
2011-10-05 17:41:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#my-actor
|
|
|
|
|
|
2011-12-08 14:06:20 +01:00
|
|
|
case class DoIt(msg: ImmutableMessage)
|
2011-12-06 16:49:39 +01:00
|
|
|
case class Message(s: String)
|
|
|
|
|
|
|
|
|
|
//#context-actorOf
|
|
|
|
|
class FirstActor extends Actor {
|
2011-12-16 00:39:29 +01:00
|
|
|
val myActor = context.actorOf(Props[MyActor], name = "myactor")
|
2011-12-06 16:49:39 +01:00
|
|
|
//#context-actorOf
|
2012-02-08 13:37:00 +01:00
|
|
|
def receive = {
|
|
|
|
|
case x ⇒ sender ! x
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AnonymousActor extends Actor {
|
2011-12-06 16:49:39 +01:00
|
|
|
//#anonymous-actor
|
|
|
|
|
def receive = {
|
|
|
|
|
case m: DoIt ⇒
|
2011-12-13 14:09:40 +01:00
|
|
|
context.actorOf(Props(new Actor {
|
2011-12-06 16:49:39 +01:00
|
|
|
def receive = {
|
|
|
|
|
case DoIt(msg) ⇒
|
|
|
|
|
val replyMsg = doSomeDangerousWork(msg)
|
|
|
|
|
sender ! replyMsg
|
2011-12-14 00:06:36 +01:00
|
|
|
context.stop(self)
|
2011-12-06 16:49:39 +01:00
|
|
|
}
|
2011-12-08 14:06:20 +01:00
|
|
|
def doSomeDangerousWork(msg: ImmutableMessage): String = { "done" }
|
2012-02-08 10:04:47 +01:00
|
|
|
})) forward m
|
2011-12-06 16:49:39 +01:00
|
|
|
}
|
|
|
|
|
//#anonymous-actor
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#system-actorOf
|
|
|
|
|
object Main extends App {
|
|
|
|
|
val system = ActorSystem("MySystem")
|
2011-12-16 00:39:29 +01:00
|
|
|
val myActor = system.actorOf(Props[MyActor], name = "myactor")
|
2011-12-06 16:49:39 +01:00
|
|
|
//#system-actorOf
|
|
|
|
|
}
|
2011-12-08 14:06:20 +01:00
|
|
|
|
|
|
|
|
class ReplyException extends Actor {
|
|
|
|
|
def receive = {
|
|
|
|
|
case _ ⇒
|
|
|
|
|
//#reply-exception
|
|
|
|
|
try {
|
|
|
|
|
val result = operation()
|
|
|
|
|
sender ! result
|
|
|
|
|
} catch {
|
|
|
|
|
case e: Exception ⇒
|
|
|
|
|
sender ! akka.actor.Status.Failure(e)
|
|
|
|
|
throw e
|
|
|
|
|
}
|
|
|
|
|
//#reply-exception
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def operation(): String = { "Hi" }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-06 16:49:39 +01:00
|
|
|
//#swapper
|
|
|
|
|
case object Swap
|
|
|
|
|
class Swapper extends Actor {
|
|
|
|
|
import context._
|
|
|
|
|
val log = Logging(system, this)
|
|
|
|
|
|
|
|
|
|
def receive = {
|
|
|
|
|
case Swap ⇒
|
|
|
|
|
log.info("Hi")
|
|
|
|
|
become {
|
|
|
|
|
case Swap ⇒
|
|
|
|
|
log.info("Ho")
|
|
|
|
|
unbecome() // resets the latest 'become' (just for fun)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object SwapperApp extends App {
|
|
|
|
|
val system = ActorSystem("SwapperSystem")
|
2011-12-16 00:39:29 +01:00
|
|
|
val swap = system.actorOf(Props[Swapper], name = "swapper")
|
2011-12-06 16:49:39 +01:00
|
|
|
swap ! Swap // logs Hi
|
|
|
|
|
swap ! Swap // logs Ho
|
|
|
|
|
swap ! Swap // logs Hi
|
|
|
|
|
swap ! Swap // logs Ho
|
|
|
|
|
swap ! Swap // logs Hi
|
|
|
|
|
swap ! Swap // logs Ho
|
|
|
|
|
}
|
|
|
|
|
//#swapper
|
|
|
|
|
|
|
|
|
|
//#receive-orElse
|
|
|
|
|
|
|
|
|
|
abstract class GenericActor extends Actor {
|
|
|
|
|
// to be defined in subclassing actor
|
|
|
|
|
def specificMessageHandler: Receive
|
|
|
|
|
|
|
|
|
|
// generic message handler
|
|
|
|
|
def genericMessageHandler: Receive = {
|
|
|
|
|
case event ⇒ printf("generic: %s\n", event)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def receive = specificMessageHandler orElse genericMessageHandler
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SpecificActor extends GenericActor {
|
|
|
|
|
def specificMessageHandler = {
|
|
|
|
|
case event: MyMsg ⇒ printf("specific: %s\n", event.subject)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case class MyMsg(subject: String)
|
|
|
|
|
//#receive-orElse
|
|
|
|
|
|
2012-02-01 11:46:46 +01:00
|
|
|
//#receive-orElse2
|
|
|
|
|
trait ComposableActor extends Actor {
|
|
|
|
|
private var receives: List[Receive] = List()
|
|
|
|
|
protected def registerReceive(receive: Receive) {
|
|
|
|
|
receives = receive :: receives
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def receive = receives reduce { _ orElse _ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MyComposableActor extends ComposableActor {
|
|
|
|
|
override def preStart() {
|
|
|
|
|
registerReceive({
|
|
|
|
|
case "foo" ⇒ /* Do something */
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
registerReceive({
|
|
|
|
|
case "bar" ⇒ /* Do something */
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#receive-orElse2
|
2011-11-15 11:34:39 +01:00
|
|
|
class ActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) {
|
2011-10-05 17:41:00 +02:00
|
|
|
|
2011-12-06 16:49:39 +01:00
|
|
|
"import context" in {
|
|
|
|
|
//#import-context
|
|
|
|
|
class FirstActor extends Actor {
|
|
|
|
|
import context._
|
2011-12-16 00:39:29 +01:00
|
|
|
val myActor = actorOf(Props[MyActor], name = "myactor")
|
2011-12-06 16:49:39 +01:00
|
|
|
def receive = {
|
|
|
|
|
case x ⇒ myActor ! x
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#import-context
|
|
|
|
|
|
2011-12-16 00:39:29 +01:00
|
|
|
val first = system.actorOf(Props(new FirstActor), name = "first")
|
2011-12-14 00:06:36 +01:00
|
|
|
system.stop(first)
|
2011-12-06 16:49:39 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-18 17:56:23 +02:00
|
|
|
"creating actor with AkkaSpec.actorOf" in {
|
2011-12-13 14:09:40 +01:00
|
|
|
val myActor = system.actorOf(Props[MyActor])
|
2011-10-05 17:41:00 +02:00
|
|
|
|
|
|
|
|
// testing the actor
|
|
|
|
|
|
2011-11-18 11:34:52 +01:00
|
|
|
// TODO: convert docs to AkkaSpec(Map(...))
|
2011-10-27 12:23:01 +02:00
|
|
|
val filter = EventFilter.custom {
|
|
|
|
|
case e: Logging.Info ⇒ true
|
|
|
|
|
case _ ⇒ false
|
|
|
|
|
}
|
2011-11-16 17:18:36 +01:00
|
|
|
system.eventStream.publish(TestEvent.Mute(filter))
|
|
|
|
|
system.eventStream.subscribe(testActor, classOf[Logging.Info])
|
2011-10-05 17:41:00 +02:00
|
|
|
|
|
|
|
|
myActor ! "test"
|
2012-01-11 14:14:08 +01:00
|
|
|
expectMsgPF(1 second) { case Logging.Info(_, _, "received test") ⇒ true }
|
2011-10-05 17:41:00 +02:00
|
|
|
|
|
|
|
|
myActor ! "unknown"
|
2012-01-11 14:14:08 +01:00
|
|
|
expectMsgPF(1 second) { case Logging.Info(_, _, "received unknown message") ⇒ true }
|
2011-10-05 17:41:00 +02:00
|
|
|
|
2011-11-16 17:18:36 +01:00
|
|
|
system.eventStream.unsubscribe(testActor)
|
|
|
|
|
system.eventStream.publish(TestEvent.UnMute(filter))
|
2011-10-05 17:41:00 +02:00
|
|
|
|
2011-12-14 00:06:36 +01:00
|
|
|
system.stop(myActor)
|
2011-10-05 17:41:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"creating actor with constructor" in {
|
|
|
|
|
class MyActor(arg: String) extends Actor {
|
|
|
|
|
def receive = { case _ ⇒ () }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#creating-constructor
|
|
|
|
|
// allows passing in arguments to the MyActor constructor
|
2011-12-16 00:39:29 +01:00
|
|
|
val myActor = system.actorOf(Props(new MyActor("...")), name = "myactor")
|
2011-10-05 17:41:00 +02:00
|
|
|
//#creating-constructor
|
|
|
|
|
|
2011-12-14 00:06:36 +01:00
|
|
|
system.stop(myActor)
|
2011-10-05 17:41:00 +02:00
|
|
|
}
|
2011-12-06 16:49:39 +01:00
|
|
|
|
2011-12-14 14:05:44 +01:00
|
|
|
"creating a Props config" in {
|
|
|
|
|
//#creating-props-config
|
|
|
|
|
import akka.actor.Props
|
2012-08-22 15:52:32 +02:00
|
|
|
val props1 = Props.empty
|
2011-12-14 14:05:44 +01:00
|
|
|
val props2 = Props[MyActor]
|
|
|
|
|
val props3 = Props(new MyActor)
|
|
|
|
|
val props4 = Props(
|
|
|
|
|
creator = { () ⇒ new MyActor },
|
2012-01-16 14:11:29 +01:00
|
|
|
dispatcher = "my-dispatcher")
|
2011-12-14 14:05:44 +01:00
|
|
|
val props5 = props1.withCreator(new MyActor)
|
2011-12-20 21:08:27 +01:00
|
|
|
val props6 = props5.withDispatcher("my-dispatcher")
|
2011-12-14 14:05:44 +01:00
|
|
|
//#creating-props-config
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-06 16:49:39 +01:00
|
|
|
"creating actor with Props" in {
|
|
|
|
|
//#creating-props
|
|
|
|
|
import akka.actor.Props
|
2012-10-01 20:35:19 +02:00
|
|
|
val myActor = system.actorOf(Props[MyActor].withDispatcher("my-dispatcher"),
|
|
|
|
|
name = "myactor2")
|
2011-12-06 16:49:39 +01:00
|
|
|
//#creating-props
|
|
|
|
|
|
2011-12-14 00:06:36 +01:00
|
|
|
system.stop(myActor)
|
2011-12-06 16:49:39 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-08 13:37:00 +01:00
|
|
|
"using implicit timeout" in {
|
2011-12-20 08:12:20 +01:00
|
|
|
val myActor = system.actorOf(Props(new FirstActor))
|
|
|
|
|
//#using-implicit-timeout
|
2012-06-29 13:33:20 +02:00
|
|
|
import scala.concurrent.util.duration._
|
2011-12-20 08:12:20 +01:00
|
|
|
import akka.util.Timeout
|
2012-01-18 10:18:51 +01:00
|
|
|
import akka.pattern.ask
|
2012-02-08 13:37:00 +01:00
|
|
|
implicit val timeout = Timeout(5 seconds)
|
2011-12-20 08:12:20 +01:00
|
|
|
val future = myActor ? "hello"
|
|
|
|
|
//#using-implicit-timeout
|
|
|
|
|
Await.result(future, timeout.duration) must be("hello")
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 13:37:00 +01:00
|
|
|
"using explicit timeout" in {
|
2011-12-20 08:12:20 +01:00
|
|
|
val myActor = system.actorOf(Props(new FirstActor))
|
|
|
|
|
//#using-explicit-timeout
|
2012-06-29 13:33:20 +02:00
|
|
|
import scala.concurrent.util.duration._
|
2012-01-18 10:18:51 +01:00
|
|
|
import akka.pattern.ask
|
2012-02-08 13:37:00 +01:00
|
|
|
val future = myActor.ask("hello")(5 seconds)
|
2011-12-20 08:12:20 +01:00
|
|
|
//#using-explicit-timeout
|
2012-02-08 13:37:00 +01:00
|
|
|
Await.result(future, 5 seconds) must be("hello")
|
2011-12-20 08:12:20 +01:00
|
|
|
}
|
|
|
|
|
|
2011-12-06 16:49:39 +01:00
|
|
|
"using receiveTimeout" in {
|
|
|
|
|
//#receive-timeout
|
|
|
|
|
import akka.actor.ReceiveTimeout
|
2012-06-29 13:33:20 +02:00
|
|
|
import scala.concurrent.util.duration._
|
2011-12-06 16:49:39 +01:00
|
|
|
class MyActor extends Actor {
|
2011-12-13 11:11:21 +01:00
|
|
|
context.setReceiveTimeout(30 milliseconds)
|
2011-12-06 16:49:39 +01:00
|
|
|
def receive = {
|
|
|
|
|
case "Hello" ⇒ //...
|
|
|
|
|
case ReceiveTimeout ⇒ throw new RuntimeException("received timeout")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#receive-timeout
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"using hot-swap" in {
|
|
|
|
|
//#hot-swap-actor
|
|
|
|
|
class HotSwapActor extends Actor {
|
|
|
|
|
import context._
|
|
|
|
|
def angry: Receive = {
|
|
|
|
|
case "foo" ⇒ sender ! "I am already angry?"
|
|
|
|
|
case "bar" ⇒ become(happy)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def happy: Receive = {
|
|
|
|
|
case "bar" ⇒ sender ! "I am already happy :-)"
|
|
|
|
|
case "foo" ⇒ become(angry)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def receive = {
|
|
|
|
|
case "foo" ⇒ become(angry)
|
|
|
|
|
case "bar" ⇒ become(happy)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#hot-swap-actor
|
2011-12-08 14:06:20 +01:00
|
|
|
|
2011-12-16 00:39:29 +01:00
|
|
|
val actor = system.actorOf(Props(new HotSwapActor), name = "hot")
|
2011-12-06 16:49:39 +01:00
|
|
|
}
|
2011-12-28 13:09:56 +01:00
|
|
|
|
2012-06-12 15:51:54 +02:00
|
|
|
"using Stash" in {
|
|
|
|
|
//#stash
|
|
|
|
|
import akka.actor.Stash
|
|
|
|
|
class ActorWithProtocol extends Actor with Stash {
|
|
|
|
|
def receive = {
|
|
|
|
|
case "open" ⇒
|
|
|
|
|
unstashAll()
|
|
|
|
|
context.become {
|
|
|
|
|
case "write" ⇒ // do writing...
|
|
|
|
|
case "close" ⇒
|
|
|
|
|
unstashAll()
|
|
|
|
|
context.unbecome()
|
|
|
|
|
case msg ⇒ stash()
|
|
|
|
|
}
|
|
|
|
|
case msg ⇒ stash()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#stash
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-28 13:09:56 +01:00
|
|
|
"using watch" in {
|
|
|
|
|
//#watch
|
|
|
|
|
import akka.actor.{ Actor, Props, Terminated }
|
|
|
|
|
|
|
|
|
|
class WatchActor extends Actor {
|
|
|
|
|
val child = context.actorOf(Props.empty, "child")
|
2011-12-28 16:50:57 +01:00
|
|
|
context.watch(child) // <-- this is the only call needed for registration
|
2011-12-28 13:09:56 +01:00
|
|
|
var lastSender = system.deadLetters
|
|
|
|
|
|
|
|
|
|
def receive = {
|
|
|
|
|
case "kill" ⇒ context.stop(child); lastSender = sender
|
|
|
|
|
case Terminated(`child`) ⇒ lastSender ! "finished"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#watch
|
|
|
|
|
val a = system.actorOf(Props(new WatchActor))
|
|
|
|
|
implicit val sender = testActor
|
|
|
|
|
a ! "kill"
|
|
|
|
|
expectMsg("finished")
|
|
|
|
|
}
|
2012-01-03 11:41:49 +01:00
|
|
|
|
|
|
|
|
"using pattern gracefulStop" in {
|
|
|
|
|
val actorRef = system.actorOf(Props[MyActor])
|
|
|
|
|
//#gracefulStop
|
|
|
|
|
import akka.pattern.gracefulStop
|
2012-06-29 16:06:26 +02:00
|
|
|
import scala.concurrent.Await
|
2012-01-03 11:41:49 +01:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
val stopped: Future[Boolean] = gracefulStop(actorRef, 5 seconds)(system)
|
|
|
|
|
Await.result(stopped, 6 seconds)
|
|
|
|
|
// the actor has been stopped
|
|
|
|
|
} catch {
|
2012-10-01 20:35:19 +02:00
|
|
|
// the actor wasn't stopped within 5 seconds
|
|
|
|
|
case e: akka.pattern.AskTimeoutException ⇒
|
2012-01-03 11:41:49 +01:00
|
|
|
}
|
|
|
|
|
//#gracefulStop
|
2012-01-20 18:09:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"using pattern ask / pipeTo" in {
|
|
|
|
|
val actorA, actorB, actorC, actorD = system.actorOf(Props.empty)
|
|
|
|
|
//#ask-pipeTo
|
2012-02-01 14:04:01 +01:00
|
|
|
import akka.pattern.{ ask, pipe }
|
2012-07-22 21:40:09 +02:00
|
|
|
import system.dispatcher // The ExecutionContext that will be used
|
2012-01-20 18:09:26 +01:00
|
|
|
case class Result(x: Int, s: String, d: Double)
|
|
|
|
|
case object Request
|
|
|
|
|
|
|
|
|
|
implicit val timeout = Timeout(5 seconds) // needed for `?` below
|
|
|
|
|
|
|
|
|
|
val f: Future[Result] =
|
|
|
|
|
for {
|
|
|
|
|
x ← ask(actorA, Request).mapTo[Int] // call pattern directly
|
2012-09-06 03:17:51 +02:00
|
|
|
s ← (actorB ask Request).mapTo[String] // call by implicit conversion
|
|
|
|
|
d ← (actorC ? Request).mapTo[Double] // call by symbolic name
|
2012-01-20 18:09:26 +01:00
|
|
|
} yield Result(x, s, d)
|
|
|
|
|
|
|
|
|
|
f pipeTo actorD // .. or ..
|
2012-02-01 14:04:01 +01:00
|
|
|
pipe(f) to actorD
|
2012-01-20 18:09:26 +01:00
|
|
|
//#ask-pipeTo
|
2012-01-03 11:41:49 +01:00
|
|
|
}
|
2012-01-20 18:09:26 +01:00
|
|
|
|
2012-02-06 12:18:08 +01:00
|
|
|
"replying with own or other sender" in {
|
|
|
|
|
val actor = system.actorOf(Props(new Actor {
|
|
|
|
|
def receive = {
|
|
|
|
|
case ref: ActorRef ⇒
|
|
|
|
|
//#reply-with-sender
|
|
|
|
|
sender.tell("reply", context.parent) // replies will go back to parent
|
|
|
|
|
sender.!("reply")(context.parent) // alternative syntax (beware of the parens!)
|
|
|
|
|
//#reply-with-sender
|
|
|
|
|
case x ⇒
|
|
|
|
|
//#reply-without-sender
|
|
|
|
|
sender ! x // replies will go to this actor
|
|
|
|
|
//#reply-without-sender
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
implicit val me = testActor
|
|
|
|
|
actor ! 42
|
|
|
|
|
expectMsg(42)
|
|
|
|
|
lastSender must be === actor
|
|
|
|
|
actor ! me
|
|
|
|
|
expectMsg("reply")
|
|
|
|
|
lastSender must be === system.actorFor("/user")
|
|
|
|
|
expectMsg("reply")
|
|
|
|
|
lastSender must be === system.actorFor("/user")
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-25 12:18:44 +02:00
|
|
|
"using ActorDSL outside of akka.actor package" in {
|
|
|
|
|
import akka.actor.ActorDSL._
|
|
|
|
|
actor(new Act {
|
|
|
|
|
superviseWith(OneForOneStrategy() { case _ ⇒ Stop; Restart; Resume; Escalate })
|
|
|
|
|
superviseWith(AllForOneStrategy() { case _ ⇒ Stop; Restart; Resume; Escalate })
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-05 17:41:00 +02:00
|
|
|
}
|