Hello, I am using Akka 2.0 & it doesn't support getContext().getMailboxSize();. I want to get Mail Akka Box size so that i can stop producing request. I read somewhere like can create custom Mail Box through which can get the size. Can you provide JAVA samples for creating custom mail box?
On Wednesday, October 2, 2013 at 7:08:21 PM UTC+5:30, Björn Antonsson wrote: > > Hi NT, > > -- > Björn Antonsson > Typesafe <http://typesafe.com/> – Reactive Apps on the JVM > twitter: @bantonsson <http://twitter.com/#!/bantonsson> > > On Tuesday, 1 October 2013 at 18:19, NT wrote: > > Hi, thanks for your answer! > unfortunately i try your solution too, but the problem is still there. > > I minimize my scenario, you can find the sbt project here: > https://www.dropbox.com/s/zkvtz9ei0o0fxis/minimale.tar.gz > > Note that i create an abstract class (BlockingMessageQueue) implementing > QueueBasedMessageQueue (so it implement MultipleConsumerSemantics too). > MultipleConsumerSemantics is a marker trait required from the balancing > dispatcher, so the create method of my PriorityMailbox return > an instance of my BlockingMessageQueue instead of a classic MessageQueue. > > I found this info here: > > http://doc.akka.io/japi/akka/2.2.1/akka/dispatch/MultipleConsumerSemantics.html > > I've tryed several combinations in the configuration of the dispatcher > (see Main class, the configuration is readed from string) but no one worked > for me... > > NT > > > Thank you very much for the minimized example. There was only one thing > missing from your mailbox implementation. For the requirements mapping to > work, it needs to implement the ProducesMessageQueue<T> interface. Your > code works if you change to using the mailbox-requirement in your main > class and change your mailbox class first line to this: > > public class PriorityMailbox implements MailboxType, > ProducesMessageQueue<BlockingMessageQueue> > > B/ > > > > > > On Monday, September 30, 2013 9:05:55 PM UTC+2, NT wrote: > > Hi, I'm tryng to use a balancing dispatcher with a custom mailbox! > Unfortunately I'm unable to make it work with akka 2.2.1 (while it work > perfectly with akka 2.1.4) > > This is my configuration file: > > akka { > actor { > my-dispatcher { > type = BalancingDispatcher > mailbox-type = "path.to.MyMailbox" > mailbox-push-timeout-time = 10s > mailbox-capacity = 1000 > // mailbox-requirement = "path.to.MyBlockingMessageQueue" > throughput = 100 > } > > } > > > When i try to start an actor using this dispatcher > [.withDispatcher("akka.actor.my-dispatcher")] i've the following errors: > > 1) COMMENTING MAILBOX_REQUIREMENT: > > [info] configuration problem while creating > [akka://CommSigPrioritizerActorSystem/user/CommSigPrioritizer1] with > dispatcher [akka.actor.my-dispatcher] and mailbox > [akka.actor.default-mailbox] > [info] akka.ConfigurationException: configuration problem while creating > [akka://CommSigPrioritizerActorSystem/user/CommSigPrioritizer1] with > dispatcher [akka.actor.prioritizer-my-dispatcher] and mailbox > [akka.actor.default-mailbox] > [info] at > akka.actor.LocalActorRefProvider.actorOf(ActorRefProvider.scala:723) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.actor.dungeon.Children$class.makeChild(Children.scala:191) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > akka.actor.dungeon.Children$class.attachChild(Children.scala:42) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.actor.ActorCell.attachChild(ActorCell.scala:338) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:518) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > unibo.quasit.model.prioritizer.PrioritySystemFactory.startPrioritySystem(PrioritySystemFactory.java:55) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager.instantiatePrioritizer(OperatorManager.scala:413) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager.instantiateOperator(OperatorManager.scala:349) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager.deployRuntimeComponents(OperatorManager.scala:209) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager.unibo$quasit$qrn$OperatorManager$$handleMessage(OperatorManager.scala:135) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager$$anonfun$receive$1.applyOrElse(OperatorManager.scala:100) > > ~[classes/:na] > [info] at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.actor.ActorCell.invoke(ActorCell.scala:456) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.dispatch.Mailbox.run(Mailbox.scala:219) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386) > > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) > ~[scala-library.jar:na] > [info] at > scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) > > ~[scala-library.jar:na] > [info] at > scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) > ~[scala-library.jar:na] > [info] at > scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) > > ~[scala-library.jar:na] > [info] Caused by: java.lang.IllegalArgumentException: produced message > queue type [interface akka.dispatch.MessageQueue] does not fulfill > requirement for dispatcher [akka.actor.my-dispatcher] > [info] at > akka.dispatch.Mailboxes.verifyRequirements$1(Mailboxes.scala:145) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.dispatch.Mailboxes.getMailboxType(Mailboxes.scala:156) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > akka.actor.LocalActorRefProvider.actorOf(ActorRefProvider.scala:718) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] ... 19 common frames omitted > > > 2) UNCOMMENTING MAILBOX_REQUIREMENT: > > [info] configuration problem while creating > [akka://CommSigPrioritizerActorSystem/user/CommSigPrioritizer1] with > dispatcher [akka.actor.my-dispatcher] and mailbox > [akka.actor.default-mailbox] > [info] akka.ConfigurationException: configuration problem while creating > [akka://CommSigPrioritizerActorSystem/user/CommSigPrioritizer1] with > dispatcher [akka.actor.my-dispatcher] and mailbox > [akka.actor.default-mailbox] > [info] at > akka.actor.LocalActorRefProvider.actorOf(ActorRefProvider.scala:723) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.actor.dungeon.Children$class.makeChild(Children.scala:191) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > akka.actor.dungeon.Children$class.attachChild(Children.scala:42) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.actor.ActorCell.attachChild(ActorCell.scala:338) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:518) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > unibo.quasit.model.prioritizer.PrioritySystemFactory.startPrioritySystem(PrioritySystemFactory.java:55) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager.instantiatePrioritizer(OperatorManager.scala:414) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager.instantiateOperator(OperatorManager.scala:349) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager.deployRuntimeComponents(OperatorManager.scala:209) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager.unibo$quasit$qrn$OperatorManager$$handleMessage(OperatorManager.scala:135) > > ~[classes/:na] > [info] at > unibo.quasit.qrn.OperatorManager$$anonfun$receive$1.applyOrElse(OperatorManager.scala:100) > > ~[classes/:na] > [info] at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.actor.ActorCell.invoke(ActorCell.scala:456) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.dispatch.Mailbox.run(Mailbox.scala:219) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386) > > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) > ~[scala-library.jar:na] > [info] at > scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) > > ~[scala-library.jar:na] > [info] at > scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) > ~[scala-library.jar:na] > [info] at > scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) > > ~[scala-library.jar:na] > [info] Caused by: akka.ConfigurationException: Mailbox Mapping for [class > unibo.quasit.model.prioritizer.mailbox.BlockingMessageQueue] not configured > [info] at akka.dispatch.Mailboxes.lookupId(Mailboxes.scala:176) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.dispatch.Mailboxes.lookupByQueueType(Mailboxes.scala:83) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > akka.dispatch.BalancingDispatcherConfigurator.<init>(Dispatchers.scala:218) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > akka.dispatch.Dispatchers.configuratorFrom(Dispatchers.scala:151) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > akka.dispatch.Dispatchers.lookupConfigurator(Dispatchers.scala:92) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at akka.dispatch.Dispatchers.lookup(Dispatchers.scala:75) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] at > akka.actor.LocalActorRefProvider.actorOf(ActorRefProvider.scala:717) > ~[akka-actor_2.10-2.2.0.jar:2.2.0] > [info] ... 19 common frames omitted > > > Seems the system try to start my actor with the right dispatcher but wth > the default mailbox (instead of my custom mailbox) > > I read this paragraph in Mailboxes section of akka documentation: > > _______________________________________________-- > Requiring a Message Queue Type for a Dispatcher > A dispatcher may also have a requirement for the mailbox type used by the > actors running on it. An example is the BalancingDispatcher which requires > a message queue that is thread-safe for multiple concurrent consumers. Such > a requirement is formulated within the dispatcher configuration section > like this: > > my-dispatcher { > mailbox-requirement = org.example.MyInterface > } > > > The given requirement names a class or interface which will then be > ensured to be a supertype of the message queue’s implementation. In case of > a conflict—e.g. if the actor requires a mailbox type which does not satisfy > this requirement—then actor creation will fail. > _________________________________________________________ > > > > this is why i try with mailbox-requirements spec, but still doesn't work. > > > The create method of my mailbox, return a BoundendMessageQueue (an > abstract class implementing BoundedQueueBasedMessageQueue) and my mailbox > works perfectly with other types of dispatcher... > > maybe someone can help me... > > thanks in advance > > > NT > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: http://akka.io/faq/ > >>>>>>>>>> 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 <javascript:>. > To post to this group, send email to akka...@googlegroups.com > <javascript:>. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- >>>>>>>>>> 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.