Reputation: 7915
I want to add and remove actors to a pool (group?) that should receive messages through a router using consistent hash mapping (message has id which is consistent with path of entity). But after creation of the pool there is only the IActorRef returned and I don't know how to "Tell" about new Actors to add.
I have read several tutorials and hints about routing, for example this: https://github.com/petabridge/akka-bootcamp/tree/master/src/Unit-3/lesson2 but these don't fit.
Maybe I need to write an own router with these messages myself?
Upvotes: 2
Views: 1005
Reputation: 7915
There are predefined messages within the Akka.Routing package which allows to add and remove new routees. you can find the code lines in Akka.net here. For example the following code adds an IActorRef to an existing router (I tested this with ConsistentHashingGroup):
var routee = Routee.FromActorRef(actor);
router.Tell(new AddRoutee(routee));
A little bit annoying that I had to crawl through the source code to find the way how to do this because it is not part of petabridge's bootcamp (or did I overlooked it?) and I did't found an answer anywhere else even though I think this is a very typical and common scenario. The documentation is somewhat rudimental in this field.
Hopefully, this helps someone out there to safe some minutes of lifetime and do somewhat more interesting on the domain of the software to develop with Akka.net instead of searching how to use this framework. ;-)
Upvotes: 6