Akka不加载application.conf

huangapple go评论72阅读模式
英文:

Akka doesn't load application.conf

问题

我正试图设置不同的akka.http.parsing.max-chunk-size

我的application.conf文件位于src/resources/,内容如下:

akka.http {
   parsing {
       max-chunk-size=20m
   }
}

我在主程序中使用以下代码来设置系统:

val conf = ConfigFactory.load()
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer() 
implicit val executionContext = system.dispatcher

然而,当我尝试进行一个大的GET请求时,仍然会出现以下错误:

akka.http.scaladsl.model.EntityStreamException: HTTP chunk size exceeds the configured limit of 1048576 bytes

编辑:根据我得到的答案,我已经尝试重新定位文件,但是仍然遇到相同的错误。我的程序结构如下:

├── main
│   ├── resources
│   │   └── application.conf
│   └── scala
│       ├── program
│       │   ├── BackTester.scala
│       │   ├── Main.scala
│       │   └── StrategyExecutor.scala
│       ├── strategies
│       │   ├── BollingerBandStrategy.scala
│       │   ├── CrossingSMAStrategy.scala
│       │   ├── RSIStrategy.scala
│       │   ├── StochasticStrategy.scala
│       │   └── TradingStrategies.scala
│       └── util
│           ├── Interval.scala
│           ├── JsonParser.scala
│           ├── Time.scala
│           ├── barseries
│           │   └── barSeriesBuilder.scala
│           └── requests
│               └── Fetcher.scala
└── test
    └── scala
英文:

I am trying to set a different akka.http.parsing.max-chunk-size

My application.conf is in src/resources/ and looks like this:

akka.http {
   parsing {
       max-chunk-size=20m
   }
}

I am using this code in my main to set up my system:

val conf = ConfigFactory.load()
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer() 
implicit val executionContext = system.dispatcher

However I still get this error when trying to make a big get request:

akka.http.scaladsl.model.EntityStreamException: HTTP chunk size exceeds the configured limit of 1048576 bytes

EDIT: I have tried relocating the file based on the answer I got, however i still get the same error. My program structure looks like this:

├── main
│   ├── resources
│   │   └── application.conf
│   └── scala
│       ├── program
│       │   ├── BackTester.scala
│       │   ├── Main.scala
│       │   └── StrategyExecutor.scala
│       ├── strategies
│       │   ├── BollingerBandStrategy.scala
│       │   ├── CrossingSMAStrategy.scala
│       │   ├── RSIStrategy.scala
│       │   ├── StochasticStrategy.scala
│       │   └── TradingStrategies.scala
│       └── util
│           ├── Interval.scala
│           ├── JsonParser.scala
│           ├── Time.scala
│           ├── barseries
│           │   └── barSeriesBuilder.scala
│           └── requests
│               └── Fetcher.scala
└── test
    └── scala

答案1

得分: 1

我查看了官方网站,看起来配置是正确的(https://doc.akka.io/docs/akka-http/current/configuration.html)。我会将特定应用程序放入application.conf文件中,就像下面的示例一样:

routersDemo {
  akka {
    actor.deployment {
      /poolMaster2 {
        router = round-robin-pool
        nr-of-instances = 5
      }

      /groupMaster2 {
        router = round-robin-group
        routees {
          paths = ["/user/slave_1","/user/slave_2","/user/slave_3","/user/slave_4","/user/slave_5"]
        }
      }
    }
  }
}

然后在ConfigFactory中调用它:

val system = ActorSystem("routersDemo", ConfigFactory.load().getConfig("routersDemo"))
英文:

I looked at the official website and it looks like the configuration is correct (
https://doc.akka.io/docs/akka-http/current/configuration.html
). I would put inside an specific application into the application.conf file. Like this example here below.

routersDemo {
  akka {
    actor.deployment {
      /poolMaster2 {
        router = round-robin-pool
        nr-of-instances = 5
      }

      /groupMaster2 {
        router = round-robin-group
        routees {
          paths = ["/user/slave_1","/user/slave_2","/user/slave_3","/user/slave_4","/user/slave_5"]
        }
      }
    }
  }
}

And then call it at the ConfigFactory

    val system = ActorSystem("routersDemo", ConfigFactory.load().getConfig("routersDemo"))

huangapple
  • 本文由 发表于 2020年10月25日 03:59:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/64517494.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定