简体   繁体   English

在单独的进程中部署Akka.net actor

[英]Deployment of Akka.net actors in separate processes

I started to learn the Actor model (using Akka.net) and plan to use it in the current project. 我开始学习Actor模型(使用Akka.net)并计划在当前项目中使用它。 My current task is extracting text from different files using IFilter. 我当前的任务是使用IFilter从不同的文件中提取文本。 IFilter is a set of COM-servers with native code. IFilter是一组具有本机代码的COM服务器。 Sometimes it can hang or processing proceeds too long. 有时它会挂起或处理收益太久。 I need to abort a processing for problem file in such situation and continue for next file in a queue. 我需要在这种情况下中止对问题文件的处理,并继续在队列中的下一个文件。 But I need to kill a whole process for correctly cleanup the native code. 但我需要杀死整个过程以正确清理本机代码。

Another problem is the productivity – in most cases I cannot load more than one core using many threads in a single process. 另一个问题是生产力 - 在大多数情况下,我不能在一个进程中使用多个线程加载多个核心。 I am suspecting that IFilter has a lock inside. 我怀疑IFilter里面有锁。 But I can use the full power of CPU if I run several copies of my test app (it emulates multiprocess mode). 但是,如果我运行我的测试应用程序的多个副本(它模拟多进程模式),我可以使用CPU的全部功能。

My question is: how I can deploy some actors in separate processes ? 我的问题是: 如何在不同的流程中部署一些角色

I have found that actor's deployment strategy can be specified in configuration in this way (sample from Petabrige's lectures): 我发现可以通过这种方式在配置中指定actor的部署策略(来自Petabrige的讲座样本):

<akka>
  <hocon>
    <![CDATA[
        akka {
          actor {
            deployment {
              /charting {
                 # causes ChartingActor to run on the UI thread for WinForms
                dispatcher = akka.actor.synchronized-dispatcher
              }
            }
          }
        }
    ]]>
  </hocon>
</akka>

Other options are: 其他选择是:

  • SingleThreadDispatcher SingleThreadDispatcher
  • ThreadPoolDispatcher ThreadPoolDispatcher
  • ForkJoinDispatcher ForkJoinDispatcher

But I can't find here option for deployment in the separate process. 但我在这里找不到在单独进程中部署的选项。

How can I solve the problem? 我该如何解决这个问题?

You can use Akka.Remote and Remote Actor Deployments to accomplish this - you can deploy actors remotely into other processes across the network this way. 您可以使用Akka.Remote和Remote Actor Deployments来实现这一点 - 您可以通过这种方式将actor远程部署到网络中的其他进程中。 I lay out some of the steps in my answer here: I need to communicate with multiple remote actor systems 我在这里的答案中列出了一些步骤: 我需要与多个远程演员系统进行通信

If you'd like to see an example of how to do this, check out the RemoteDeploy sample inside the Akka.NET project: https://github.com/akkadotnet/akka.net/tree/dev/src/examples/RemoteDeploy 如果您想查看如何执行此操作的示例,请查看Akka.NET项目中的RemoteDeploy示例: https//github.com/akkadotnet/akka.net/tree/dev/src/examples/RemoteDeploy

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

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