Hello All,
First of all thanks for your prompt reply.
Sorry but i am still having doubt because i am very new to AKKA.
Right now we are running Web Application with 3 tier architecture [Actions
Layer, Business Logic Layer, Data Access Object Layer].
So i need to use AKKA after my Business Logic Layer.
For e.g.
-> Sender_BLL_1 is Non-Actor java class
1) Non-Actor Calling Java class
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
public class Sender_BLL_1 {
private void run() {
ActorSystem system = ActorSystem.create("MySystem1"); <-----
ActorRef myActor = system.actorOf(new Props(AkkaActor1.class),
"AkkaActor1");
myActor.tell("Hello");
}
}
2) First Actor
import akka.actor.UntypedActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;
public class AkkaActor1 extends UntypedActor {
LoggingAdapter log = Logging.getLogger(getContext().system(), this);
public void onReceive(Object object) throws Exception {
if (object instanceof String) {
String str = (String) object;
log.info("Received String message in AkkaActor1 : {}", str);
} else {
unhandled(object);
}
}
}
But suppose when i want call another Actor from another BLL file then again
i need to write
" ActorSystem system = ActorSystem.create("MySystem"); " for creating
ActorSystem.
For e.g.
-> Sender_BLL_2 is Non-Actor java class
1) Non-Actor Calling Java class
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
public class Sender_BLL_2 {
private void run() {
ActorSystem system = ActorSystem.create("MySystem2"); <-----
ActorRef myActor = system.actorOf(new Props(AkkaActor2.class),
"AkkaActor2");
myActor.tell("Hello");
}
}
2) Second Actor
import akka.actor.UntypedActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;
public class AkkaActor2 extends UntypedActor {
LoggingAdapter log = Logging.getLogger(getContext().system(), this);
public void onReceive(Object object) throws Exception {
if (object instanceof String) {
String str = (String) object;
log.info("Received String message in AkkaActor2 : {}", str);
} else {
unhandled(object);
}
}
}
That means i have created 2 ActorSystem for 2 Business Logic files [it will
increase as my BLL file runs] like that we are
having more then 500 Business Logic files in my Web Application.
But as i know that An ActorSystem is a heavyweight object so we need to
create only one per logical application.
So what is the way to create only 1 ActorSystem for any Web Application or
to check for existing ActorSystem.
On Monday, June 11, 2012 5:58:27 AM UTC+5:30, dimgel wrote:
>
> Hi all,
>
> Since actors are stateful, I have to create an actor tree for each HTTP
> request I handle, right?
>
> Have I to create ActorSystem for each request too, or I can create the
> only one in Servlet.init(), reuse it for all (possibly concurrent)
> requests, and shut it down in Servlet.destroy()?
>
> Is there any recommended way of generating unique ActorSystem names if
> each request needs its own ActorSystem, or unique Actor names otherwise?
> (AFAIK names are optional and that's OK for standalone server, but anyway
> maybe someone came upon some guidelines about naming in distributed
> environment.)
>
> Thanks. =)
>
--
>>>>>>>>>> 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.