为了账号安全,请及时绑定邮箱和手机立即绑定

如何在Akka Project Java中使用Typesafe conf

如何在Akka Project Java中使用Typesafe conf

POPMUISE 2021-04-27 17:53:44
我有一个使用AKKA框架以Java编写的应用程序。我想在本地模式下运行该应用程序。配置文件application.conf:    akka{ actor {   provider = "akka.cluster.ClusterActorRefProvider" } remote {  transport = "akka.remote.netty.NettyRemoteTransport"   log-remote-lifecycle-events = off   netty.tcp {      hostname = "127.0.0.1"      port =2552      maximum-frame-size = 1048576000b      send-buffer-size = 1048576000b      receive-buffer-size = 1048576000b   } } cluster {  failure-detector {      threshold = 12      acceptable-heartbeat-pause = 240s      heartbeat-interval = 200s      heartbeat-request {        expected-response-after = 100s      }    }    seed-nodes = [   "akka.tcp://kCoreDescompositionSystem@127.0.0.1:2552",   "akka.tcp://kCoreDescompositionSystem@127.0.0.1:2553",   "akka.tcp://kCoreDescompositionSystem@127.0.0.1:2554",    ]   auto-down-unreachable-after = 10s }}我很困惑如何正确地创建Config configLocal = ConfigFactory .....
查看完整描述

1 回答

?
肥皂起泡泡

TA贡献1829条经验 获得超6个赞

创建configLocal对象时,您可以使用ConfigFactory.load()从文件中加载配置。


final Config configLocal = ConfigFactory.parseString("akka.cluster.roles = [masterRole] ").

    //  withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.port=0" )).

        withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.hostname = \"127.0.0.1\"")).

            //withFallback(ConfigFactory.parseString("akka.cluster.role.workerRole.min-nr-of-members = " +nbWorkers)).

        withFallback(ConfigFactory.parseString("akka.cluster.seed-nodes = [\"akka.tcp://MasterMain@127.0.0.1:2552\"]")).

            withFallback(ConfigFactory.load());


查看完整回答
反对 回复 2021-05-12
  • 1 回答
  • 0 关注
  • 160 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信