Does Akka.conf dispatcher configuration work?

I am using Akka 2.2-RC1 and I cannot get Akka to load the dispatcher configuration from application.conf:

my-dispatcher { type = PinnedDispatcher executor = "thread-pool-executor" } akka.actor.deployment { /test { dispatcher = my-dispatcher } } 

When creating an instance from type code

  val test = system.actorOf(Props[Test], "test") 

akka.actor.default-dispatcher it still uses akka.actor.default-dispatcher .

When I add .withDispatcher("my-dispatcher") to Props, everything works correctly and my-dispatcher . But I don't like the idea of ​​adding .withDispatcher(...) to all of my actors ...

Does anyone know where there might be a problem? I thought the path to the actor might be wrong, but the apllication.conf routing configuration works correctly (except for the custom route manager, again).


After some testing, I found that this effect is caused by using RemoteActorRefProvider . As soon as I disabled it and changed to default

 akka.actor.provider = "akka.actor.LocalActorRefProvider" 
Dispatchers

configured correctly from the configuration.

I believe that with remote activation, Akka looks in a different place for setting up dispatcher actors, or perhaps remote links have different logical paths?

+4
source share
1 answer

This worked fine for me in the same version of akka that you used. My configuration:

 test{ my-dispatcher { type = PinnedDispatcher executor = "thread-pool-executor" } akka.actor.deployment { /test-actor { dispatcher = my-dispatcher } } } 

My code is:

 object ActorTest{ def main(args: Array[String]) { val conf = ConfigFactory.load() val system = ActorSystem("test", conf.getConfig("test")) val ref = system.actorOf(Props[TestActor], "test-actor") } } class TestActor extends Actor{ def receive = { case _ => } } 

I used jconsole and showed that the attached dispatcher was listed on the Threads tab

+6
source

Source: https://habr.com/ru/post/1486132/


All Articles