Hi all,
I tried to use a custom dispatcher as described in
http://akka.io/docs/akka/2.0-M4/scala/dispatchers.html:
val configString = """
akka {
logConfigOnStart=on
actor {
my-dispatcher {
# Dispatcher is the name of the event-based dispatcher
type = Dispatcher
# ...
}
}
}
"""
Due to the "logConfigOnStart=on" parameter I verified that the Akka
system started with the custom dispatcher declared.
I try to use the dispatcher like this:
system = ActorSystem("DispatcherTest",
ConfigFactory.parseString(configString))
val workerActor =
system.actorOf(Props().withCreator(config.workerFactory.createInstance(workerId,
config)).withDispatcher("my-dispatcher"), name = workerName)
When executing the code this results in the following warning:
[Dispatchers] Dispatcher [my-dispatcher] not configured, using
default-dispatcher
Am I using this wrong or missing something obvious? Thank you very
much for your help.
An additional question that I have been wondering about: What's the
advantage of specifying the configuration using a configuration file
compared to doing it programmatically with the builder pattern? Having
a configuration statically checked while writing it and being able to
use code completion is very nice. Also it would probably simplify
writing code that extends an existing configuration; manually
concatenating string fragments is error prone and not very elegant.
the dispatcher (configurator) would have to be serializable in your scenario, which while possible seems not desirable because such a thing might want to hang on to some nasty things like thread pools and some such. Of course that can be done right, but it's much harder to get wrong in the current scheme.
Regards,
Roland