4
votes

I'm using Akka 2.2-RC1 and I'm not able to get Akka to load dispatcher configuration from application.conf:

my-dispatcher {
  type = PinnedDispatcher
  executor = "thread-pool-executor"
}

akka.actor.deployment {
  /test {
    dispatcher = my-dispatcher
  }
}

When instantiated from code like

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

by logs it is still using akka.actor.default-dispatcher.

When I'm adding .withDispatcher("my-dispatcher") to Props all is working properly and my-dispatcher is used. But I do not like idea of adding .withDispatcher(...) to all my actors...

Do anyone know where could be a problem? I was thinking that actor path may be wrong, but apllication.conf routing configuration works properly (with exception of custom routee dispatcher, again).


After some testing I've found that this effect is caused by use of RemoteActorRefProvider. As soon as I disabled it and changed to default

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

dispatchers were configuring from config properly.

I guess with remoting enabled Akka looks elsewhere for configuration of actor dispatchers or maybe remote refs have different logical paths?

1

1 Answers

6
votes

This worked fine for me on the same version of akka that you were using. My config:

test{
  my-dispatcher {
    type = PinnedDispatcher
    executor = "thread-pool-executor"
  }

  akka.actor.deployment {
    /test-actor {
      dispatcher = my-dispatcher
    }
  }
}

My code:

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 shows that the pinned dispatcher was listed under the Threads tab