Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I wait for all work to complete in Akka.Net?

Tags:

akka.net

I have successfully sent work to a pool of actors to perform my work, but now I want to do some aggregation on the results returned by all the workers. How do I know that everyone is done?

The best I have come up with is to maintain a set of requests ids and wait for that set to go to zero, but this seems inelegant.

like image 947
Damian Avatar asked May 06 '15 19:05

Damian


People also ask

How do actors communicate in Akka?

Actors communicate using asynchronous messages. This ensures that the sender does not stick around waiting for their message to be processed by the recipient. Instead, the sender puts the message in the recipient's mailbox and is free to do other work.

Is Akka net free?

Akka.NET Bootcamp is a free, self-directed learning course brought to you by the folks at Petabridge. Over the three units of this bootcamp you will learn how to create fully-functional, real-world programs using Akka.NET actors and many other parts of the core Akka.NET framework. Start Bootcamp here.

What is Akka net framework?

Akka.NET is a toolkit and runtime for building highly concurrent, distributed, and fault tolerant event-driven applications on . NET & Mono. This community-driven port brings C# & F# developers the capabilities of the original Akka framework in Java/Scala.


1 Answers

Generally, you want to use what we call the "Commander" pattern for this. Essentially, you have one stateful actor (the Commander) that is responsible for starting and monitoring the task. You then farm out the actual work across the actor pool, and have them report back to the Commander as they finish. The commander can then track the progress of the job by calculating # completions / size of worker pool.

This way, the workers can be monitored and restarted independently as they do the work, but all the precious task-level state and information lives in the Commander (this is called the "Error Kernel pattern")

You can see an example of this in the Akka.NET scalable webcrawler demo.

like image 105
AndrewS Avatar answered Oct 08 '22 12:10

AndrewS