Thanks Martynas, That makes it clear . I just wanted to make sure since I 
assumed by having setup cluster it will by default perform the load 
balancing work on the incoming messages

So seeing up akka.cluster.ClusterActorRefProvider , Just creates bunch of 
nodes in a cluster setup where they know about each other but they don't 
talk to each other unless you make them talk , e.g, using Cluster Aware 
Routers to route messages.


-Rajesh
 

On Friday, January 23, 2015 at 9:31:19 AM UTC-8, Martynas Mickevičius wrote:
>
> Hi Rajesh,
>
> you are explicitly sending messages to /user/HelloActor actor running on 
> [email protected]:2551. This is encoded in the path you provide to 
> actorSelection. No message reaches another node, because you are sending 
> every message to a first node.
>
> You will need to setup a Cluster Aware Router 
> <http://doc.akka.io/docs/akka/2.3.9/java/cluster-usage.html#Cluster_Aware_Routers>
>  to 
> route messages across actors running on multiple nodes.
>
> On Thu, Jan 22, 2015 at 12:25 AM, Rajesh Shetty <[email protected] 
> <javascript:>> wrote:
>
>> I have setup cluster of 2 nodes using following config
>>
>> akka {
>>
>> log-dead-letters = 10
>>
>>   log-dead-letters-during-shutdown = on
>>
>>   actor {
>>
>>     provider = "akka.cluster.ClusterActorRefProvider"
>>
>>   }
>>
>>   remote {
>>
>>     log-remote-lifecycle-events = off
>>
>>     netty.tcp {
>>
>>       hostname = "127.0.0.1"
>>
>>       port = 0
>>
>>     }
>>
>>   }
>>
>>
>>   cluster {
>>
>>   min-nr-of-members = 2
>>
>>     seed-nodes = [
>>
>>       "akka.tcp://[email protected]:2551",
>>
>>       "akka.tcp://[email protected]:2552"]
>>
>>
>>     auto-down-unreachable-after = 10s
>>
>>   }
>>
>> }
>>
>>
>>
>> public static class HelloActor extends UntypedActor {
>>
>>     final ActorRef worldActor = getContext().actorOf(Props.create
>> (WorldActor.class));
>>
>>
>>     public void onReceive(Object message) {
>>
>>       if (message.equals("start"))
>>
>>       {
>>
>>         worldActor.tell("Hello", getSelf());
>>
>>       }
>>
>>       else if (message instanceof String)
>>
>>       {
>>
>>     String s =String.format("Received message '%s' from '%s'", message, 
>> getSender().toString());
>>
>>         System.out.println(s);
>>
>>         try
>>
>>         {
>>
>>                 //intentional sleep to emulate nodex - HelloActor to be 
>> busy.
>>
>>         Thread.sleep(10000);
>>
>>         }
>>
>>         catch(Exception e)
>>
>>         {
>>
>>         e.printStackTrace();
>>
>>         System.out.println("exception while thread sleeping");
>>
>>         }
>>
>>         System.out.println("HelloActor on current node done processing.."
>> );
>>
>>       }
>>
>>       else
>>
>>         unhandled(message);
>>
>>     }
>>
>>   }
>>
>> public static class WorldActor extends UntypedActor {
>>
>>     public void onReceive(Object message) {
>>
>>       if (message instanceof String)
>>
>>         getSender().tell(((String) message).toUpperCase() + " world!",
>>
>>             getSelf());
>>
>>       else
>>
>>         unhandled(message);
>>
>>     }
>>
>>   }
>>
>>
>>
>> and each of the node is just simple microkernel bootable hello actor and 
>> world actor. 
>>
>>
>> Im calling akka cluster from the Play app. I'm calling leader node (the 
>> one runnning on 2551) using following code multiple times every second , it 
>> keeps sending message to node1 and not doing work distribution to node2 
>> since node1 actor is still busy (10 secs sleep)
>>
>>
>>
>>
>> public Result testAkka(String name)
>>
>> {
>>
>> ActorSystem actorSystem = ActorSystem.create( "hellokernel" );
>>
>> ActorSelection myActor = actorSystem.actorSelection("akka.tcp://
>> [email protected]:2551/user/HelloActor" );
>>
>> myActor.tell(name, null);
>>
>> return Results.ok("message sent");
>>
>>  }
>>
>>
>>
>>
>> So my question is 
>>
>>
>> > for balancing of load/messages to happen - do we have to setup routers 
>> or is it a default functionality of cluster 
>>
>> > if answer is yes (we do have to setup router) how do I do it?
>>
>> > if answer is no (means default cluster leader should send message to 
>> node2 , if node1 is busy) , why is it above example not working.
>>
>>
>>
>>
>>
>>
>>
>>
>>  -- 
>> >>>>>>>>>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Martynas Mickevičius
> Typesafe <http://typesafe.com/> – Reactive 
> <http://www.reactivemanifesto.org/> Apps on the JVM
>  

-- 
>>>>>>>>>>      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