How it works...
In this recipe, we learned how to use the Master-Worker (or Slave) work pulling pattern. This pattern is usually applied to gain control over the flow of incoming messages to be able to distribute the load more evenly and act when it is not possible to process more work.
In this particular example, the MasterWorkPulling actor controls the flow of messages. First, when a new worker joins, it registers it into its internal registry, where it keeps track of which workers are busy and which ones are idle. Also, it starts watching them in case they are no longer alive. The master actor also holds a queue of the pending work tasks. This is to maintain a buffer of pending work items instead of directly rejecting work when all workers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access