简体   繁体   English

Akka BalancingDispatcher配置

[英]Akka BalancingDispatcher Config

I have created a file application.conf in src/main/resources that looks like this: 我在src / main / resources中创建了一个文件application.conf,如下所示:

balancing-dispatcher {
  type = BalancingDispatcher
  executor = "thread-pool-executor"
}

There is nothing else in the file. 文件中没有其他内容。

Upon creating a new Actor (through my test suite using Akka TestKit) that tries to use the dispatcher, I receive this error message: 在创建一个尝试使用调度程序的新Actor(通过我使用Akka TestKit的测试套件)时,我收到以下错误消息:

[WARN] [04/13/2013 21:55:28.007] [default-akka.actor.default-dispatcher-2] [Dispatchers] Dispatcher [balancing-dispatcher] not configured, using default-dispatcher

My program then runs correctly, albeit using only a single thread. 然后我的程序正确运行,尽管只使用一个线程。

Furthermore, I intend to package my program into a library. 此外,我打算将我的程序打包成一个库。 The akka docs state this: akka文档声明:

If you are writing an Akka application, keep you configuration in application.conf at
the root of the class path. If you are writing an Akka-based library, keep its 
configuration in reference.conf at the root of the JAR file.

I have tried both of these methods so far, but neither has worked. 到目前为止,我已尝试过这两种方法,但两种方法都没有效果。

Any ideas? 有任何想法吗?

Since your application.conf is not found I can only assume that src/main/resources is not part of your build path (cannot comment further without knowing which tool you use for building). 由于找不到您的application.conf我只能假设src/main/resources不是您的构建路径的一部分(如果不知道您用于构建的工具,则无法进一步评论)。

One small thing: why do you use "thread-pool-executor" in there? 一件小事:为什么你在那里使用"thread-pool-executor" We found the default "fork-join-executor" to scale better. 我们发现默认的"fork-join-executor"可以更好地扩展。

Your comment about the one thread suggests that you are creating just one actor; 你对这个帖子的评论表明你只创造了一个演员; using a BalancingDispatcher does not automagically create more actors, you will have to tell Akka to do that somehow (eg creating multiple instance of that same actor manually or via a Router ). 使用BalancingDispatcher不会自动创建更多的actor,你必须告诉Akka以某种方式这样做(例如手动或通过Router创建同一个actor的多个实例)。

The question of reference.conf vs. application.conf is more one of the nature of the settings. reference.confapplication.conf的问题更多是设置的本质之一。 If your library wants to get its own settings from the config, then default values should go into reference.conf ; 如果您的库想要从配置中获取自己的设置,那么默认值应该进入reference.conf ; that is the design concept and the reason why this file is always implicitly merged in. Defaults should only be in that file, never in the code. 这就是设计概念以及此文件始终隐式合并的原因。默认值应仅在该文件中,而不是在代码中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM