[akka-user] Trying to configure ActorSystems
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. -- >> 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+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
Re: [akka-user] Trying to configure ActorSystems
Remove the import system.dispatcher and you will see that you need to provide an ExecutionContext, which you can lookup from the config, via the system.dispatchers.lookup (I think) fre 29 jan. 2016 kl. 01:42 skrev Ian Nowland : > 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. > > -- > >> 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+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- >> 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+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
Re: [akka-user] Trying to configure ActorSystems
So, I've tried replacing the import system.dispatcher with implicit val executionContext = system.dispatchers.lookup("akka.actor.habari-function-scheduler-dispatcher") but I'm still getting the system.dispatcher as the akka.default On Friday, January 29, 2016 at 12:34:28 PM UTC-5, Patrik Nordwall wrote: > > Remove the import system.dispatcher and you will see that you need to > provide an ExecutionContext, which you can lookup from the config, via the > system.dispatchers.lookup (I think) > > fre 29 jan. 2016 kl. 01:42 skrev Ian Nowland >: > >> 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. >> >> -- >> >> 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. >> > -- >> 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+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.