问题描述
我正在浏览Akka文档&其他维基。谁能告诉我Dispatcher& and之间的区别是什么? Akka框架中的路由器?
I am going through akka documentation & other wiki's. Can anyone tell me what is the difference between Dispatcher & Routers in Akka framework?
推荐答案
Dispatcher
和路由器
是Actor系统的两个不同概念。调度程序基本上是一个线程池,这意味着可以使用调度程序执行任意代码,当然,您可以自定义线程池的配置(在fork-join池和线程执行程序之间进行选择,设置最大/最小并行度,请检查默认的 dispatcher conf
)。虽然路由器一词与部署过程有关,并且指定了将消息路由到路由列表的路由逻辑,但是您可以在其中为池/组选择合适的策略(例如RoundRobin,Broadcast等),指定路由器路径(对于
Dispatcher
and Routers
are two different concepts of Actor System. A dispatcher is basically a thread-pool, which means that dispatchers can be used to execute arbitrary code, of course, you can customize a configuration of thread pool (select between fork-join pool and thread executor, set up max/min parallelism level, check default dispatcher conf
reference.conf ). While term "Routers" is related to deployment process and specifying routing logic to route messages to a list of routees, where you can select a suitable strategy for pool/group (like RoundRobin, Broadcast, etc.), specify router paths (for a group).
来自规范:
Dispatcher是Akka Actors的代号,是引擎的引擎可以这么说,
机器可以用来执行任意代码,例如
实例期货
Dispatcher is what makes Akka Actors "tick", it is the engine of the machine so to speak, they can be used to execute arbitrary code, for instance Futures
可以看到,它们都对Actor系统的绝对不同部分负责,但是您可以将它们两者组合在一起以定制相同的actor系统配置。有关更多详细信息,请参见。 HTH
As you see, both of them are responsible for an absolutely different part of Actor System, but you can combine both of them for customization of the same actor system configuration. For more details, check this article. HTH
这篇关于Akka中的Dispatcher和Routers之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!