简体   繁体   中英

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. My current task is extracting text from different files using IFilter. IFilter is a set of COM-servers with native code. 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. But I can use the full power of CPU if I run several copies of my test app (it emulates multiprocess mode).

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):

<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
  • ThreadPoolDispatcher
  • 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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