How it works...
In this recipe, we covered how to distribute messages evenly to a pool of actors using two different approaches. Both are similar; however, they do not behave exactly the same. The balancing dispatcher tries to distribute the messages as evenly as possible. This happens thanks to having only one mailbox that is shared among all the routee actors. In the logs, when we execute BalancingDispatcherApp, we can see how the messages are getting processed: all actors from $a to $e get a message before any of them get a second message. Then, we see the actors processing messages using the $a -> $b -> $d -> $c pattern and then starting with $a again. We should not worry about not getting an alphabetical sequence since all routees are ...
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