16 apr 2014 kl. 23:26 skrev √iktor Ҡlang <[email protected]>:
> Hi Vitaly, > > On Wed, Apr 16, 2014 at 11:24 PM, vitaly tamazyan <[email protected]> wrote: > Good point, thanks! > I think this corner case should be noted in the documentation on Broadcast > messages, because now it says: > "A Broadcast message can be used to send a message to all of a router's > routees. > When a router receives aBroadcast message, it will broadcast that message's > payload to all routees, no matter how that router would normally route its > messages. > > It is hard to connect a problem with routing to the type of dispatcher. > > But the above is still true. It sends the message to all routees, and since > they share the same mailbox, you get N messages in that mailbox, and those > messages will be processed on a first-come-first-served basis. I think there is an opportunity here to improve the BalancingDispatcher in not allowing the Broadcast message ;-) Any takers? Regards, Roland > > > > четверг, 17 апреля 2014 г., 0:03:10 UTC+3 пользователь √ написал: > Hi Vitaly, > > Actors who have a BalancingDispatcher are sharing the same mailbox instance. > Your observed behavior is perfectly expected. > > > On Wed, Apr 16, 2014 at 11:00 PM, vitaly tamazyan <[email protected]> wrote: > When I try to tell a Broadcast message to routees with BalancingDispatcher, I > get strange behavior -- some actors get the message twice, and some -- not at > all. > Same thing happens if I manually iterate through routee's actorRefs and > send a message directly to them. This I believe is not right. > When I use another types of dispatchers, everything works as expected. > tested on akka 2.2.4, java 7, linux mint 16 > > See example code below: > > public void test() { > ActorSystem system = ActorSystem.create("test"); > > Props routeeProps = > Props.create(Worker.class).withDispatcher("akka.workerDispatcher"); > > List<ActorRef> routees = new ArrayList<>(); > > for (int i = 16; i > 0; i--) { > ActorRef actor = system.actorOf(routeeProps, "Worker" + i); > routees.add(actor); > } > > ActorRef workers = system.actorOf( > Props.empty().withRouter(RoundRobinRouter.create(routees) > .withDispatcher("akka.managerDispatcher")),"Workers"); > > for (int i = 0; i < 10; i++) { > workers.tell(new Broadcast("test" + i), null); > } > } > > > public class Worker extends UntypedActor { > private LoggingAdapter logger = > Logging.getLogger(getContext().system().eventStream(), this); > private Random r = new Random(); > > @Override > public void onReceive(Object message) throws Exception { > logger.debug(getSelf().path().name() + " " + message); > Thread.sleep(100 * r.nextInt(10)); // emulate load > } > } > > > application.conf > > akka { > workerDispatcher { > executor = "thread-pool-executor" > type = BalancingDispatcher > } > > managerDispatcher { > executor = "thread-pool-executor" > type = Dispatcher > } > > loggers = ["akka.event.slf4j.Slf4jLogger"] > loglevel="DEBUG" > > log-dead-letters-during-shutdown = off > } > > output: > ..... > 23:43:04.234 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker3 > test9 > 23:43:04.333 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker5 > test9 > 23:43:04.334 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker1 > test9 > 23:43:04.335 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker13 > test9 > 23:43:04.336 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker9 > test9 > 23:43:04.433 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker6 > test9 > 23:43:04.434 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker7 > test9 > 23:43:04.435 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker16 > test9 > 23:43:04.633 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker14 > test9 > 23:43:04.637 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker4 > test9 > 23:43:04.733 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker5 > test9 > 23:43:04.734 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker10 > test9 > 23:43:04.735 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker1 > test9 > 23:43:04.736 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker14 > test9 > 23:43:04.833 [test-akka.actor.default-dispatcher-4] DEBUG Worker - Worker5 > test9 > > > > > -- > >>>>>>>>>> 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 [email protected]. > To post to this group, send email to [email protected]. > > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > > > > -- > Cheers, > √ > > -- > >>>>>>>>>> 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > > > > -- > Cheers, > √ > > -- > >>>>>>>>>> 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. Dr. Roland Kuhn Akka Tech Lead Typesafe – Reactive apps on the JVM. twitter: @rolandkuhn -- >>>>>>>>>> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
