Hello,
I'm trying to configure an ActorSystem, but no matter what I do, seem to be getting the default dispatcher. Here's what I've got going on:
val customConf = ConfigFactory.parseString(
"""
|akka {
|
| actor{
|
| /function-scheduler {
| dispatcher = function-scheduler-dispatcher
| }
|
| function-scheduler-dispatcher {
| type = Dispatcher
| executor = "fork-join-executor"
| fork-join-executor {
| # Min number of threads
| parallelism-min = 2
| # available processors * factor
| parallelism-factor = 4.0
| # Max number of threads
| parallelism-max = 32
| }
| }
| }
|
|}
""".stripMargin)
val system:ActorSystem = ActorSystem("function-scheduler",ConfigFactory.load(customConf))
import system.dispatcher
def scheduleOnce(delayTime: Long)(f:() => Unit):Unit = {
import scala.language.postfixOps
system.scheduler.scheduleOnce(delayTime milliseconds) {
f()
}
}
As you can see, what I'm trying to do is use a scheduler to be able to schedule arbitrary tasks. The problem is that everything I've tried in that customConf still results in system using the akka.actor.default-dispatcher. I definitely don't understand how the configuration stuff works, but my theory is that I'm configuring the dispatcher that would be used for created ActorRefs if I was to call something like:
val myActor = system.actorOf(Props[MyActor].withDispatcher("function-scheduler-dispatcher"), "myactor1")
rather than configuring the system itself.