可以为每个Actor指定自定义Route或自定义构造函数参数 [英] Possible to specify custom Routees or custom constructor arguments for each Actor
问题描述
我想这可能是不可能的,因为需要重新创建角色的监督策略,但是我是否能够将自定义角色提供给路由器?或至少是:自定义构造函数参数?
I imagine this might not be possible because of supervision strategies needing to recreate actors, nevertheless am I able to feed custom actors to a Router? Or at the very least: custom constructor arguments?
如果没有,为什么akka不允许这样做?不应以这种方式使用路由吗?我正在顺便使用BalancingPool。
If no, why doesn't akka allow this? Is routing not suppose to be used in this way? I am using a BalancingPool by the way.
在Scala中这似乎有可能但我无法在java中弄清楚这一点。
This seems to be possible in Scala How to create routers in akka with parameterized actors? but I haven't been able to figure this out in java.
推荐答案
池是不可能的,因为池从相同的道具$ c $创建多个实例c>定义,但通常可以使用路由。来自文档:
It is not possible with a pool, since a pool creates multiple instances of from the same Props
definition, but it is possible with routing in general. From the docs:
这种类型的路由器角色具有两种不同的风格:
This type of router actor comes in two distinct flavors:
- 池-路由器将路由创建为子角色,如果终止则将其从路由器中删除。
- 组-路由角色在路由器外部创建然后路由器使用参与者选择
将消息发送到指定路径,而无需注意终止。
如果您创建一个组而不是一个池,该组可以包含您想要的任何参与者。
Do if you create a group rather than a pool, the group can contain whichever actors you want.
这篇关于可以为每个Actor指定自定义Route或自定义构造函数参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!