public
Created

Akka on JRuby

  • Download Gist
Gemfile
Ruby
1
gem "jbundler"
Jarfile
1 2 3
source "http://repo.typesafe.com/typesafe/releases/"
 
jar "com.typesafe.akka:akka-actor", "2.0.2"
test.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
 
require "bundler/setup"
require "jbundler"
require "java"
 
java_import "akka.actor.ActorSystem"
java_import "akka.actor.UntypedActor"
java_import "akka.actor.UntypedActorFactory"
java_import "akka.actor.Props"
 
class Someone < UntypedActor
def onReceive(message)
puts "onReceive: #{message}"
getContext.system.shutdown
 
sleep 1
puts "Close"
end
end
 
class SomeoneFactory
java_implements UntypedActorFactory
def create
Someone.new
end
end
 
system = ActorSystem.apply("test-system")
someone = system.actorOf(Props.new(SomeoneFactory.new))
 
someone.tell "hello"
 
system.awaitTermination

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.