akka 简单例子总是 not delivered和dead letters encountered,求大神帮看下

DunkOnly
  • 612
package spark;
import akka.actor.{ Actor, Props, ActorSystem, ExtendedActorSystem }
import com.typesafe.config.ConfigFactory
import akka.remote._

object MyApp extends App {
  val actorSystem1 = ActorSystem("actorSystem1", ConfigFactory.parseString("""
    akka {
      remote {
        enabled-transports = ["akka.remote.netty.tcp"]
        netty.tcp {
          hostname = "127.0.0.1"
          port = 5155
        }
       }
    }
   """))
  val actorSystem2 = ActorSystem("actorSystem2")

  actorSystem1.actorOf(Props(new Actor {
    def receive = {
      case x: String =>
        Thread.sleep(1000)
        println("RECEIVED MESSAGE: " + x)
    }
  }), "simplisticActor")

  val remoteActor = actorSystem2.actorSelection("akka.tcp://[email protected]:" + 5155 + "/user/simplisticActor")

  remoteActor ! "TEST 1"
  remoteActor ! "TEST 2"
  remoteActor ! "TEST 2"

  Thread.sleep(1000)

  actorSystem1.shutdown()
  actorSystem2.shutdown()
}
回复
阅读 6.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏