Trying to load configurations

28 views
Skip to first unread message

Ian Nowland

unread,
Jun 9, 2016, 1:29:05 PM6/9/16
to Akka User List
I'm trying to test that I'm loading configurations properly, and just can't seem to create the configuration properly - and getting nowhere in tracking down what I'm doing wrong on my own.

Here's a configuration I've created just to try and verify things are working:

TaskScheduler {
  dispatcher = TaskScheduler-dispatcher
}

TaskScheduler-dispatcher {
  type = Dispatcher
  executor = "thread-pool-executor"
  thread-pool-executor {
    fixed-pool-size = 1
  }
}

My code that's loading the configuration is following this example, and is succeeding without error:

private def combine(content:String,name:String) =
  StringUtils.filterEmpty(content).flatMap(conf => {
    Try(ConfigFactory.parseString(conf)).recoverWith({
      case t:Throwable =>
        Log.warn(s"Unable to parse akka configuration ${name}",t)
        Failure(t)
    }).toOption
  }).flatMap(config => {
    Try(ConfigFactory.load(config.withFallback(typesafeConfig))).recoverWith({
      case t:Throwable =>
        Log.warn(s"Unable to apply akka configuration ${name} with default configuration",t)
        Failure(t)
    }).toOption
  }).foreach(config => {
    Log.info(s"Setting akka configuration to include ${name}")
    BaseConfiguration.typesafeConfig = config})

However, my code to actually take advantage of the configuration looks like this, and is failing:

Try({
  Log.info(s"Found akka configuration for $configName as ${BaseConfiguration.typesafeConfig.getAnyRef(_configName)}")
  val _system = ActorSystem(_configName)
  Log.info(s"Found akka dispatcher configuration for ${dispatcherName(_configName)} as ${BaseConfiguration.typesafeConfig.getAnyRef(dispatcherName(_configName))}")
  _system.dispatchers.lookup(dispatcherName(_configName))
}).recoverWith({
  case t:Throwable =>
  Log.debug(s"When loading akka configuration ${_configName}:",t)
  Failure(t)
})


showing up like this:


INFO [2016-06-09 17:17:58,036] habari: [ewdE8B4L]Found akka configuration for Some(TaskScheduler) as {dispatcher=TaskScheduler-dispatcher} 
INFO [2016-06-09 17:17:58,042] habari: [ewdE8B4L]Found akka dispatcher configuration for TaskScheduler-dispatcher as {executor=thread-pool-executor, thread-pool-executor={fixed-pool-size=1}, type=Dispatcher} 
DEBUG [2016-06-09 17:17:58,043] habari: [ewdE8B4L]When loading akka configuration TaskScheduler:Dispatcher [TaskScheduler-dispatcher] not configured: akka.ConfigurationException: Dispatcher [TaskScheduler-dispatcher] not configured

I think there's something simple that I'm missing just in the name of the dispatcher I'm asking for, but there doesn't seem to be any way to list the names of the dispatchers the ActorSystem has, so I can't figure out any way to check what the dispatcher I've configured is actually called. Can anyone clue me in on what I'm doing wrong?

Ian Nowland

unread,
Jun 9, 2016, 3:05:15 PM6/9/16
to Akka User List
Further investigation has shown me that the same configurations, added to my BaseConfiguration do work, so something about the load of this secondary file is causing the configuration to be un-runnable.

Martynas Mickevičius

unread,
Jun 24, 2016, 1:37:34 AM6/24/16
to akka...@googlegroups.com
Hi,

it looks like you are not passing your custom parsed and loaded configuration to actor system constructor: ActorSystem(_configName).

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Ian Nowland

unread,
Jun 27, 2016, 12:24:37 PM6/27/16
to Akka User List
Ah, thanks. I had thought the ActorSystem was a singleton of some sort.
Reply all
Reply to author
Forward
0 new messages