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.

Reply via email to