Skip to content

Instantly share code, notes, and snippets.

@casualjim
Created January 3, 2012 09:24
Show Gist options
  • Save casualjim/1554237 to your computer and use it in GitHub Desktop.
Save casualjim/1554237 to your computer and use it in GitHub Desktop.
package testing
import akka.actor._
object Main {
def main(args: Array[String]) {
val sys1 = ActorSystem("first")
val sys2 = ActorSystem("second")
sys1.actorOf(Props(new Actor {
def receive = {
case m => {
println("The first actor received")
println(m)
println("from: %s".format(sender))
sender ! ('reply, m)
}
}
}), "tester")
sys2.actorOf(Props(new Actor {
def receive = {
case 'send => {
println("Sending a message")
val a = context.system.actorFor("akka://first/user/tester")
println("to: %s".format(a))
a ! "The message"
}
case ('reply, m) => {
println("The second actor received")
println(m)
sys1.shutdown
sys2.shutdown
}
}
}), "tester")
println("using sys1")
sys1.actorFor("akka://first/user/tester") ! "A message using sys1"
println("using sys2")
sys2.actorFor("akka://first/user/tester") ! "A message using sys2"
println("using the actor")
sys2.actorFor("/user/tester") ! 'send
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment