Akka Actors communicate example
In this example, we will discuss how Actors communicate with each other, which means how one Actor sends a message to second Actor, and how it receives and processes the messages from the second Actor:

Follow these steps to develop and test this akkacommunicate-app
application:
- Create an SBT Project in IDE. Here, I'll use
helloworld-app
as my SBT project name. - Add the
akka-actor
module configuration to thebuild.sbt
file:
build.sbt:
name := "akkacommunicate-app" version := "1.0" scalaVersion := "2.12.2" libraryDependencies ++= Seq("com.typesafe.akka" %% "akka-actor" % "2.5.9")
- Create greeting messages as Case classes and Case object(s), as shown:
GreetingMessages.scala:
package com.packt.publishing.reactive.communicate case class GoodMorning(name: String) case object HowDoYouDo case class GoodBye(name: String)
- Create
PersonOneActor
with its messages processing logic, as illustrated:
PersonOneActor.scala:
...