Add dispatcher to deployment config, see #2839
This commit is contained in:
parent
7e79bcd4ae
commit
ae0cb4a756
18 changed files with 293 additions and 76 deletions
|
|
@ -103,6 +103,14 @@ object DispatcherDocSpec {
|
|||
//Other dispatcher configuration goes here
|
||||
}
|
||||
//#prio-dispatcher-config-java
|
||||
|
||||
//#dispatcher-deployment-config
|
||||
akka.actor.deployment {
|
||||
/myactor {
|
||||
dispatcher = my-dispatcher
|
||||
}
|
||||
}
|
||||
//#dispatcher-deployment-config
|
||||
"""
|
||||
|
||||
//#prio-mailbox
|
||||
|
|
@ -165,13 +173,21 @@ class DispatcherDocSpec extends AkkaSpec(DispatcherDocSpec.config) {
|
|||
|
||||
import DispatcherDocSpec.MyActor
|
||||
|
||||
"defining dispatcher" in {
|
||||
"defining dispatcher in config" in {
|
||||
val context = system
|
||||
//#defining-dispatcher
|
||||
//#defining-dispatcher-in-config
|
||||
import akka.actor.Props
|
||||
val myActor = context.actorOf(Props[MyActor], "myactor")
|
||||
//#defining-dispatcher-in-config
|
||||
}
|
||||
|
||||
"defining dispatcher in code" in {
|
||||
val context = system
|
||||
//#defining-dispatcher-in-code
|
||||
import akka.actor.Props
|
||||
val myActor =
|
||||
context.actorOf(Props[MyActor].withDispatcher("my-dispatcher"), "myactor1")
|
||||
//#defining-dispatcher
|
||||
//#defining-dispatcher-in-code
|
||||
}
|
||||
|
||||
"defining dispatcher with bounded queue" in {
|
||||
|
|
|
|||
|
|
@ -25,16 +25,8 @@ Dispatchers implement the :class:`ExecutionContext` interface and can thus be us
|
|||
Setting the dispatcher for an Actor
|
||||
-----------------------------------
|
||||
|
||||
So in case you want to give your ``Actor`` a different dispatcher than the default, you need to do two things, of which the first is:
|
||||
|
||||
.. includecode:: ../scala/code/docs/dispatcher/DispatcherDocSpec.scala#defining-dispatcher
|
||||
|
||||
.. note::
|
||||
The "dispatcherId" you specify in withDispatcher is in fact a path into your configuration.
|
||||
So in this example it's a top-level section, but you could for instance put it as a sub-section,
|
||||
where you'd use periods to denote sub-sections, like this: ``"foo.bar.my-dispatcher"``
|
||||
|
||||
And then you just need to configure that dispatcher in your configuration:
|
||||
So in case you want to give your ``Actor`` a different dispatcher than the default, you need to do two things, of which the first
|
||||
is to configure the dispatcher:
|
||||
|
||||
.. includecode:: ../scala/code/docs/dispatcher/DispatcherDocSpec.scala#my-dispatcher-config
|
||||
|
||||
|
|
@ -44,6 +36,24 @@ And here's another example that uses the "thread-pool-executor":
|
|||
|
||||
For more options, see the default-dispatcher section of the :ref:`configuration`.
|
||||
|
||||
Then you create the actor as usual and define the dispatcher in the deployment configuration.
|
||||
|
||||
.. includecode:: ../scala/code/docs/dispatcher/DispatcherDocSpec.scala#defining-dispatcher-in-config
|
||||
|
||||
.. includecode:: ../scala/code/docs/dispatcher/DispatcherDocSpec.scala#dispatcher-deployment-config
|
||||
|
||||
An alternative to the deployment configuration is to define the dispatcher in code.
|
||||
If you define the ``dispatcher`` in the deployment configuration then this value will be used instead
|
||||
of programmatically provided parameter.
|
||||
|
||||
.. includecode:: ../scala/code/docs/dispatcher/DispatcherDocSpec.scala#defining-dispatcher-in-code
|
||||
|
||||
.. note::
|
||||
The dispatcher you specify in ``withDispatcher`` and the ``dispatcher`` property in the deployment
|
||||
configuration is in fact a path into your configuration.
|
||||
So in this example it's a top-level section, but you could for instance put it as a sub-section,
|
||||
where you'd use periods to denote sub-sections, like this: ``"foo.bar.my-dispatcher"``
|
||||
|
||||
Types of dispatchers
|
||||
--------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue