Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BadShakespeareanActor

  • Loading branch information...
commit b81b24b6486f8b516a927b447dc91e15814d15db 0 parents
@stig authored
3  .gitignore
@@ -0,0 +1,3 @@
+.idea/
+.idea_modules/
+target/
13 build.sbt
@@ -0,0 +1,13 @@
+name := "AkkaConcurrency"
+
+version := "0.1.0-SNAPSHOT"
+
+scalaVersion := "2.10.0"
+
+resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
+
+libraryDependencies ++=
+ "com.typesafe.akka" %% "akka-actor" % "2.1.0" ::
+ "org.scalatest" %% "scalatest" % "1.9.1" % "test" ::
+ Nil
+
1  project/build.properties
@@ -0,0 +1 @@
+sbt.version=0.12.2
36 src/main/scala/zzz/akka/investigation/BadShakespeareanActor.scala
@@ -0,0 +1,36 @@
+package zzz.akka.investigation
+
+// All that's needed for now are three components from Akka
+
+import akka.actor.{Actor, Props, ActorSystem}
+
+// Our Actor
+class BadShakespeareanActor extends Actor {
+ // The 'Business Logic'
+ def receive = {
+ case "Good Morning" =>
+ println("Him: Forsooth 'tis the 'morn, but mourneth for thou doest I do!")
+ case "You're terrible" =>
+ println("Him: Yup")
+
+ }
+}
+
+object BadShakespeareanMain {
+ val system = ActorSystem("BadShakespearean")
+ val actor = system.actorOf(Props[BadShakespeareanActor], "Shake")
+
+ // We'll use this utility method to talk with our Actor
+ def send(msg: String) {
+ println(s"Me: $msg")
+ actor ! msg
+ Thread.sleep(100)
+ }
+
+ // And our driver
+ def main(args: Array[String]) {
+ send("Good Morning")
+ send("You're terrible")
+ system.shutdown()
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.