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