Make MailboxType implementation configurable. See #1484
* Added mailboxType property to dispatcher config * Changed durable mailboxes to use this * Updated docs for durable mailboxes
This commit is contained in:
parent
6e3c2cb682
commit
61813c6635
10 changed files with 183 additions and 119 deletions
|
|
@ -4,15 +4,18 @@
|
|||
package akka.docs.actor.mailbox
|
||||
|
||||
//#imports
|
||||
import akka.actor.Actor
|
||||
import akka.actor.Props
|
||||
import akka.actor.mailbox.FileDurableMailboxType
|
||||
|
||||
//#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 = {
|
||||
|
|
@ -20,14 +23,31 @@ class MyActor extends Actor {
|
|||
}
|
||||
}
|
||||
|
||||
class DurableMailboxDocSpec extends AkkaSpec {
|
||||
object DurableMailboxDocSpec {
|
||||
val config = """
|
||||
//#dispatcher-config
|
||||
my-dispatcher {
|
||||
mailboxType = akka.actor.mailbox.FileBasedMailbox
|
||||
}
|
||||
//#dispatcher-config
|
||||
"""
|
||||
}
|
||||
|
||||
"define dispatcher with durable mailbox" in {
|
||||
//#define-dispatcher
|
||||
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), name = "myactor")
|
||||
//#define-dispatcher
|
||||
val myActor = system.actorOf(Props[MyActor].withDispatcher(dispatcher))
|
||||
//#prog-define-dispatcher
|
||||
myActor ! "hello"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue