Created
February 26, 2011 02:58
-
-
Save laclefyoshi/844889 to your computer and use it in GitHub Desktop.
Jython and Remote Actor (Akka)
This file contains 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
#!/usr/bin/jython | |
# -*- coding: utf-8 -*- | |
# Copyright : (c) SAEKI Yoshiyasu | |
# License : MIT-style license | |
# <http://www.opensource.org/licenses/mit-license.php> | |
# last updated: 2011/02/26 | |
from akka.actor import Actors, UntypedActor | |
class MyActor(UntypedActor): | |
def onReceive(self, message): | |
# return message | |
self.getContext().reply("client> " + message) | |
# start remote actor binding localhost:9999 and named "hello" | |
Actors.remote().start("localhost", 9999).register("hello", | |
Actors.actorOf(MyActor)) | |
# create actor client for "hello" | |
ar = Actors.remote().actorFor("hello", "localhost", 9999) | |
# send message to remote actor | |
print ar.sendRequestReply("Hello") | |
# stop client actor | |
ar.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment