Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Akka Dispatcher programmatically

I have a scenario where I create actors on demand. I want to be able to define a Dispatcher and attach it to my actor programmatically.

The deal is: My ActorSystem is already running, which mean that it have already loaded all the Akka configurations.

Seems like the Dispatcher has to be defined in the application.conf before creating the ActorSystem, so I have two questions:

  1. Is there anyway to add new Akka configuration to an ActorSystem after it has been started?

  2. Is there another way to use Props[MyActor].withDispatcher("any-dispatcher") without the Dispatcher being defined in the ActorSystem configuration?

like image 239
Barbara Avatar asked Jul 12 '16 18:07

Barbara


1 Answers

No, the dispatchers must be configured when the actor system is started, they can not be defined dynamically.

If you have an app where you can restart the actor system the config library has options to programmatically define blocks, so you could generate a config based on the default one and then pass that config to the ActorSystem when you create it.

like image 155
johanandren Avatar answered Oct 02 '22 00:10

johanandren