Skip to content

Instantly share code, notes, and snippets.

@akkida746
Created October 18, 2016 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akkida746/536345cba65d1feab1f9c262c07b5b7f to your computer and use it in GitHub Desktop.
Save akkida746/536345cba65d1feab1f9c262c07b5b7f to your computer and use it in GitHub Desktop.
Scala Actor Demo
import akka.actor.Actor
import akka.event.Logging
import akka.actor.{Props, ActorSystem}
object ActorDemo {
def main(args: Array[String]): Unit = {
val system = ActorSystem("drinks-system")
val props = Props[DrinkActor]
val drinkActor = system.actorOf(props, "drinkActor-1")
drinkActor ! "tea"
drinkActor ! "coffee"
drinkActor ! "water"
system.terminate()
}
}
class DrinkActor extends Actor {
val log = Logging(context.system, this)
def receive = {
case "tea" => log.info("Tea time!")
case "coffee" => log.info("Coffee time!")
case _ => log.info("Hmmm...")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment