Search code examples
azure-service-fabricstateful-actor-service

Reliable Actors - share a collection between all instances?


Currently, I spawn a bunch of actors to do some long running task. I put these into a List, then call Task.WaitAll() to collect the results.

However, I want to collect the results as each Actor completes its task (rather than wait for every actor to finish and aggregate it at the end).

I was thinking about using reliable collections, but how do I share a reliable collection between all actors?

Thanks!


Solution

  • Actors are separate entities by design so you can't simply 'share' a collection between several instances. A couple of workarounds that cross my mind -

    • Spawn a dedicated actor with a fixed id and make other actors to communicate with this one when they finish their job
    • Create a separate stateful service that your actors will be accessing to store the required data
    • Have a separate resource, like EventHub, to listen for the events that actors will generate upon tasks completion