Akka actor 外部化部署配置
Akka actor externalizing deployment configuration
我正在使用
在 play 2.1.5 应用程序中实例化一个 Actor
lazy val ref = Akka.system.actorOf(Props[BackgroundProcessorActor], name = "background-processor")
我有一个指定以下配置的属性文件
application {
akka {
actor {
default-dispatcher = {
fork-join-executor {
parallelism-factor = 1.0
}
}
background-dispatcher = {
fork-join-executor {
parallelism-factor = 1.0
}
}
deployment = {
/background-processor = {
dispatcher = background-dispatcher
router = round-robin
nr-of-instances = 128
}
/solr_asset_updater = {
dispatcher = default-dispatcher
}
/solr_asset_log_updater = {
dispatcher = default-dispatcher
}
/change_queue_processor = {
dispatcher = default-dispatcher
}
}
}
}
}
我花了一些时间阅读文档和播放源代码。但是 background-processor
的部署设置,特别是 router = round-robin
和 nr-of-instances = 128
似乎没有被采用。
是否需要指定
lazy val ref = Akka.system.actorOf(Props[BackgroundProcessorActor].withRouter(FromConfig()), name = "background-processor")
这对我来说似乎是多余的。我错过了什么?
Play 的 Akka 插件中的 actor 系统名为 application
,但使用的是顶层配置(不是子配置)。您可以通过设置日志级别轻松进行测试。
akka {
loglevel = "DEBUG"
actor {
...
}
}
回答问题
是否需要指定(FromConfig)
lazy val ref = Akka.system.actorOf(Props[BackgroundProcessorActor].withRouter(FromConfig()), name = "background-processor")
akka 文档中的答案
The decision whether to create a router at all, on the other hand, must be taken within the code, i.e. you cannot make something a router by external configuration alone (see below for details).
实际上需要使用 withRouter 并在代码中或使用 FromConfig[=12= 在配置中指定路由器选项]
我正在使用
在 play 2.1.5 应用程序中实例化一个 Actorlazy val ref = Akka.system.actorOf(Props[BackgroundProcessorActor], name = "background-processor")
我有一个指定以下配置的属性文件
application {
akka {
actor {
default-dispatcher = {
fork-join-executor {
parallelism-factor = 1.0
}
}
background-dispatcher = {
fork-join-executor {
parallelism-factor = 1.0
}
}
deployment = {
/background-processor = {
dispatcher = background-dispatcher
router = round-robin
nr-of-instances = 128
}
/solr_asset_updater = {
dispatcher = default-dispatcher
}
/solr_asset_log_updater = {
dispatcher = default-dispatcher
}
/change_queue_processor = {
dispatcher = default-dispatcher
}
}
}
}
}
我花了一些时间阅读文档和播放源代码。但是 background-processor
的部署设置,特别是 router = round-robin
和 nr-of-instances = 128
似乎没有被采用。
是否需要指定
lazy val ref = Akka.system.actorOf(Props[BackgroundProcessorActor].withRouter(FromConfig()), name = "background-processor")
这对我来说似乎是多余的。我错过了什么?
Play 的 Akka 插件中的 actor 系统名为 application
,但使用的是顶层配置(不是子配置)。您可以通过设置日志级别轻松进行测试。
akka {
loglevel = "DEBUG"
actor {
...
}
}
回答问题
是否需要指定(FromConfig)
lazy val ref = Akka.system.actorOf(Props[BackgroundProcessorActor].withRouter(FromConfig()), name = "background-processor")
akka 文档中的答案
The decision whether to create a router at all, on the other hand, must be taken within the code, i.e. you cannot make something a router by external configuration alone (see below for details).
实际上需要使用 withRouter 并在代码中或使用 FromConfig[=12= 在配置中指定路由器选项]