262728293031323334
for (int i = 1; i <= 10; i++) { // sends randomly to actors randomRouter.tell(i); } _system.shutdown(); } }
34353637383940414243
ActorRef router = _system.actorOf(new Props() .withRouter(BroadcastRouter.create(routees))); router.tell("Hello there"); _system.shutdown(); } }
18192021222324252627
for (int i = 1; i <= 13; i++) { //sends series of messages in a round robin way to all the actors burstyMessageRouter.tell(i); } _system.shutdown(); } }
20212223242526272829
for (int i = 1; i <= 10; i++) { //works like roundrobin but tries to rebalance the load based on //size of actor's mailbox smallestMailBoxRouter.tell(i); } _system.shutdown(); } }
2425262728293031323334
actor.tell("Hello"); Thread.sleep(500); system.shutdown(); } @Override public void onReceive(Object message) throws Exception {
19202122232425262728
for (int i = 1; i <= 2; i++) { //same message goes to all the actors broadcastRouter.tell(i); } _system.shutdown(); } }
202122232425262728
for (int i = 1; i <= 10; i++) { //sends randomly to actors randomRouter.tell(i); } _system.shutdown(); } }
30313233343536373839
Future<Object> futureResult = akka.pattern.Patterns.ask( scatterGatherFirstCompletedRouter, "message", timeout); String result = (String) Await.result(futureResult, timeout.duration()); System.out.println(result); _system.shutdown(); } }
252627282930313233
if (i == 5) { TimeUnit.MILLISECONDS.sleep(100); System.out.println("\n"); } } _system.shutdown(); } }
for (int i = 0; i < 5; i++) updateThreads[i].start(); Thread.sleep(3000); _system.shutdown(); } }