我的之前的代码
package com.tydic.demo
import akka.actor.{ActorSystem, Props}
import com.typesafe.config.ConfigFactory
/*
*/ object Entrance {
def main(args: Array[String]): Unit = {
// 创建actorSystem 管理所有的actor对象
val config =
s"""
|akka.actor.provider = "akka.remote.RemoteActorRefProvider"
|akka.remote.netty.tcp.hostname = "192.168.75.1"
|akka.remote.netty.tcp.port = "8888"
|""".stripMargin
val ac = ActorSystem("actorSystem", ConfigFactory.parseString(config))
// 关联ac和workerActor
val worker = ac.actorOf(Props(WorkerActor), "workerActor")
// 发送一句话
worker ! "start"
}
}
启动以后,端口没有发生改变
解决办法
应该是新版本的配置方法变了(刚入门的菜鸟,不敢胡说)
package com.tydic.demo
import akka.actor.{ActorSystem, Props}
import com.typesafe.config.ConfigFactory
/*
*/ object Entrance {
def main(args: Array[String]): Unit = {
// 创建actorSystem 管理所有的actor对象
val config =
s"""
|akka.actor.provider = "akka.remote.RemoteActorRefProvider"
|akka.remote.artery.enable = "on"
|akka.remote.artery.canonical.hostname = "192.168.75.1"
|akka.remote.artery.canonical.port = "8888"
|""".stripMargin
val ac = ActorSystem("actorSystem", ConfigFactory.parseString(config))
// 关联ac和workerActor
val worker = ac.actorOf(Props(WorkerActor), "workerActor")
// 发送一句话
worker ! "start"
}
}