Created
January 3, 2012 09:24
-
-
Save casualjim/1554237 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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