編集通知、このhttps://github.com/akka/akka/commit/ce014ece3568938b2036c4ccfd21b92faba69607#L13L6の逆の変更を行って、受け入れられた回答をakkasホームページにある安定分布であるAKKA2.1で機能させる必要がありました。
AKKAで見つけたすべてのチュートリアルを読みましたが、「箱から出して」動作するものは見つかりませんでした。
Eclipseを使用して、2つのプログラムを作成したいと思います。
Program1:アクター「joe」を開始し、どういうわけか127.0.0.1:some_portで利用可能にします
Program2:127.0.0.1:some_portでアクター「joe」への参照を取得します。「joe」にハローメッセージを送信します。
プログラム1は、メッセージの受信時に何かを出力する必要があります。この例をAKKA2.1を使用してEclipseで実行したいと思います。誰かが2つのプログラム(program1とprogram2)を、これだけを実行する作業中のapplication.confファイルと一緒にリストすることはできますか?
編集> 私がこれまでに得たものをお見せしましょう:
俳優
case class Greeting(who: String) extends Serializable
class GreetingActor extends Actor with ActorLogging {
def receive = {
case Greeting(who) ⇒ println("Hello " + who);log.info("Hello " + who)
}
}
プログラム1:
package test
import akka.actor.ActorSystem
object Machine1 {
def main(args: Array[String]): Unit = {
val system = ActorSystem("MySystem")
}
}
プログラム2
package test
import akka.actor.ActorSystem
import akka.actor.Props
import akka.actor.actorRef2Scala
object Machine2 {
def main(args: Array[String]): Unit = {
val system = ActorSystem("MySystem")
val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
greeter ! Greeting("Felix")
}
}
application.conf
akka {
actor {
deployment {
/greeter {
remote = "akka://MySystem@127.0.0.1:2553"
}
}
}
}
ただし、このプログラムは、Program2のみを起動すると機能し、次のように出力されます。
Hello Felix
[INFO] [02/18/2013 12:27:29.999] [MySystem-akka.actor.default-dispatcher-2] [akka://MySystem/user/greeter] Hello Felix
application.confを取得していないようです。eclipseプロジェクトの./src/フォルダーと./フォルダーの両方に配置してみました。変わりはない。また、これは実際には降格展開であることを知っていますが、AKKAを使用して動作するにはHelloWorldプログラムが必要です。単純に機能するアプリケーションを入手せずに、これに多くの時間を費やしました。