I have an actor setup where I have two consecutive routers. The first router is the parent of the second router. I wanted to move the configuration of these routers to the configuration file. Setting up the first router was not hard. The second one was a little tricker as the parent is different for each router.
This is an example of the actor paths:
/router1/$a/router2/$a /router1/$a/router2/$b /router1/$b/router2/$a /router1/$b/router2/$b etc.
I tried using a wildcard (*) in the configuration route, but got the following error:
com.typesafe.config.ConfigException$Parse: application.conf: 13: Reserved character '*' is not allowed outside quotes (if you intended '*' (Reserved character '*' is not allowed outside quotes) to be part of the value for 'deployment', try enclosing the value in double quotes)
After playing around a little it turns out you can use wildcards in the route, as long as it is enclosed with quotes. If I had taken the trouble to read the error message completely I would seen the hint 🙁 Anyway, problem solved. Here are the code snippets.
This is the appliction.conf:
akka { loglevel = "INFO" actor { provider = "akka.actor.LocalActorRefProvider" deployment { /controllerRouter { router = round-robin-pool resizer { lower-bound = 1 upper-bound = 2 } } "/controllerRouter/*/downloaderRouter" { router = round-robin-pool resizer { lower-bound = 1 upper-bound = 4 } } } } }
This is the code for the first router:
val controllerRouter = system.actorOf(FromConfig.props(Props[Controller]), "controllerRouter")
This is the code for the second router:
downloaderRouter = context.actorOf(FromConfig.props(Props(new Downloader(monitor))), "downloaderRouter")
I hope this saves someone time.