Blog Archives

01: Simple Akka tutorial in Java step by step

Why use Akka? Akka handles all of the underlying threading complexities by allowing you to just focus on dividing your tasks into actors, defining messages to pass among actors, and wiring together their communication logic.

The real power of Akka is realized when you distribute actors across multiple machines. You could spin off hundreds of Akka servers to run your actors, and the Akka toolkit seamlessly handles the distribution and communication of the messages among the actors.

Step 1: Create a simple Java based Maven project. “-B” is to run the maven archetype plugin in non-intercative mode. In order to learn how to set up maven, look at Setting up Java, Maven, and Eclipse.

Step 2: Import the “simple-akka” into eclipse.

File –> Import –> “Existing Maven Projects” –> “select the pom.xml” file that gets created from the step 1 in the folder “c:\projects\simple-akka”.

Step 3: Open the “pom.xml” file within the imported project and add the “akka-actor_2.10” library as dependency.

Read more ...


01: Simple Akka Tutorial in Scala step by step for the Java developers

Simple Akka Tutorial in Scala step by step with Maven. This is reactive programming in action, which is used for message driven interactions. This extends setting up Scala and Simple Akka tutorial in Java step by step

Step 1: Create a scala maven project named “simple-akka-scala” as shown below.

Step 2: Import the maven scala project “simple-akka-scala” into “Scala IDE” (i.e Eclipse Scala Plugin).

File –> Import –> “Existing Maven Projects” –> “Browse” –> simple-akka-scala.

Step 3: Delete the test scala files *.scala under “src/test/scala” as they will not compile.

Step 4: Modify the pom.xml file as shown below with 2.11 scala libraries.

Read more ...


02: Simple Akka tutorial in Java with 2 Actors

This tutorial extends the previous tutorial Simple Akka tutorial in Java step by step to use multiple actors. Let’s have two different actors to handle odd and even numbers respectively. We will also print the thread names. Step 1: Actor “ConsumerOfOddNumbers.java” that runs on the “actor.default-dispatcher-xx” thread.

Step 2:…

Read more ...


02: Simple Akka tutorial in Scala with 2 Actors

This tutorial extends the previous tutorial Simple Akka Tutorial in Scala step by step for the Java developers, and Simple Akka tutorial in Java with 2 Actors.

Step 1: The “Consumer.scala” file that contains two actor classes “ConsumerOfOddNumbers” and “ConsumerOfEvenNumbers“. In Scala, you can have multiple classes in a single file as shown below.

Step 2: The “Producer.scala”… Read more ...



03: Akka tutorial “ask” request – response pattern in Java

This tutorial extends the previous tutorial Simple Akka tutorial in Java step by step to apply the Ask pattern. Tell is a “Fire-and-Forget” pattern, and whereas an “ask” sends a message with a Future for the response. Request-Response pattern in Akka with “Ask” Step 1: The “Producer.java” using the “ask”…

Read more ...


03: Akka tutorial “ask” request – response pattern Scala way

This tutorial extends Simple Akka Tutorial in Scala step by step for the Java developers and Akka tutorial “ask” request – response pattern in Java. Request-Response pattern in Akka with “Ask” Step 1: The “Producer.java” using the “ask” pattern to send a mesage and then receive response via a Future…

Read more ...


04: Akka tutorial “tell-tell” request – response pattern in Java

This tutorial extends the previous tutorial Simple Akka tutorial in Java step by step and Akka tutorial “ask” request – response pattern in Java. Step 1: The “Producer.java” is an actor now. It receives messages from both “ProducerConsumerMain.java”, which is a “DeadLetterActorRef” and the “Consumer.java”, which is an actor.

Read more ...


05: Akka tutorial in Java – calculating the factorials concurrently

This tutorial extends the previous tutorial Simple Akka tutorial in Java step by step. This is a non trivial example of calculating the factorial for a range of numbers in parallel. Step 1: The main class “FactorialCalculatorMain.java” takes a range: start and end as input arguments, and constructs an “Input.java”…

Read more ...


06: Simple Akka remoting tutorial in Java – producer & consumer

This tutorial extends the previous tutorial Simple Akka tutorial in Java step by step. This tutorial is all about remote actors. In other words, inter process communication. The “ProducerMain.java” and “ConsumerMain.java” run as different processes in host “127.0.0.1” on ports 5225 & 2552 respectively. The protocol used to communicate is…

Read more ...


500+ Enterprise & Core Java programmer & architect Q&As

Java & Big Data Tutorials

Top