How to tell when all actors idle? #6177
-
I have an application that queues up a bunch of messages for some actors to run when it starts up. How can I tell when all the messages in the system have been processed so I can then shut it down? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@pwhe23 best way to do this would be a "roll up" process:
That would be a tidy, elastically-configurable way of solving this issue. |
Beta Was this translation helpful? Give feedback.
-
That pattern worked pretty great. Here's a little LinqPad script I threw together to test it out for anyone interested:
|
Beta Was this translation helpful? Give feedback.
@pwhe23 best way to do this would be a "roll up" process:
ReceiveTimeout
to test for when it has become idle;ReceiveTimeout
- parent actor callsContext.Watch
on each child so it will receive aTerminated
message when that child actor dies;ReceiveTimeout
message, it kills itself viaContext.Stop
- parent receives theTerminated
message and then callsContext.GetChildren
(or decrements an internal counter) to see how many children are still alive.Ac…