Dev Time: Getting rid of synchronized: Using Akka from Java
For an Actor it's transparent if there is one or a million Actors behind a reference. There is one mailbox for an Actor reference that can dispatch the messages to any amount of Actors.
Cope with Failure - Actor Supervision in Akka
Tasks can be split into several actors that communicate via immutable messages. State is encapsulated and each actor can be scaled independently. While implementing an actor you don't have to take care of low level building blocks like Threads and synchronization so it is far more easy to reason about the application.
We are using three actors: one which carries the information on the pages to be visited and visited already, one that downloads and parses the pages and one that indexes the pages in Lucene.
Read full article from Dev Time: Getting rid of synchronized: Using Akka from Java
For an Actor it's transparent if there is one or a million Actors behind a reference. There is one mailbox for an Actor reference that can dispatch the messages to any amount of Actors.
We only need to change the instanciation of the Actor, the rest of the application remains the same:
parser = getContext().actorOf(new Props(new UntypedActorFactory() {
@Override
public Actor create() {
return new PageParsingActor(pageRetriever);
}
}).withRouter(new RoundRobinRouter(10)));
By using a router the Akka framework automatically takes care that there are 10 Actors available. The messages are distributed to any available Actor. This takes the runtime down to 2 seconds.
http://www.reactive.io/tips/2014/03/28/getting-started-with-actor-based-programming-using-scala-and-akka/Cope with Failure - Actor Supervision in Akka
Tasks can be split into several actors that communicate via immutable messages. State is encapsulated and each actor can be scaled independently. While implementing an actor you don't have to take care of low level building blocks like Threads and synchronization so it is far more easy to reason about the application.
We are using three actors: one which carries the information on the pages to be visited and visited already, one that downloads and parses the pages and one that indexes the pages in Lucene.
Read full article from Dev Time: Getting rid of synchronized: Using Akka from Java