pekko/akka-docs/modules/code/akka/docs/actor/mailbox/DurableMailboxDocSpec.scala
Patrik Nordwall 61813c6635 Make MailboxType implementation configurable. See #1484
* Added mailboxType property to dispatcher config
* Changed durable mailboxes to use this
* Updated docs for durable mailboxes
2011-12-19 21:41:02 +01:00

54 lines
1.3 KiB
Scala

/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.docs.actor.mailbox
//#imports
import akka.actor.Props
//#imports
//#imports2
import akka.actor.mailbox.FileDurableMailboxType
//#imports2
import org.scalatest.{ BeforeAndAfterAll, WordSpec }
import org.scalatest.matchers.MustMatchers
import akka.testkit.AkkaSpec
import akka.actor.Actor
class MyActor extends Actor {
def receive = {
case x
}
}
object DurableMailboxDocSpec {
val config = """
//#dispatcher-config
my-dispatcher {
mailboxType = akka.actor.mailbox.FileBasedMailbox
}
//#dispatcher-config
"""
}
class DurableMailboxDocSpec extends AkkaSpec(DurableMailboxDocSpec.config) {
"configuration of dispatcher with durable mailbox" in {
//#dispatcher-config-use
val dispatcher = system.dispatcherFactory.lookup("my-dispatcher")
val myActor = system.actorOf(Props[MyActor].withDispatcher(dispatcher), name = "myactor")
//#dispatcher-config-use
}
"programatically define dispatcher with durable mailbox" in {
//#prog-define-dispatcher
val dispatcher = system.dispatcherFactory.newDispatcher(
"my-dispatcher", throughput = 1, mailboxType = FileDurableMailboxType).build
val myActor = system.actorOf(Props[MyActor].withDispatcher(dispatcher))
//#prog-define-dispatcher
myActor ! "hello"
}
}