Skip to content

Instantly share code, notes, and snippets.

@laclefyoshi
Created February 26, 2011 02:58
Show Gist options
  • Save laclefyoshi/844889 to your computer and use it in GitHub Desktop.
Save laclefyoshi/844889 to your computer and use it in GitHub Desktop.
Jython and Remote Actor (Akka)
#!/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