I am trying to use the pub/sub pattern in a cluster. The documentation on this is VERY poor.
The scenario I am looking for is: 1. an actor subscribes to an event. 2. anywhere in the code, publish a message to all the subscribers on this event in the actor system, without selecting the actors.
From the "existing" documentation, the way to do that is using: DistributedPubSub.Get(Context.System).Mediator;
However, once I initiate a Mediator, I get an "association" exception.
Thanks
Are you truly looking to send the same message to all actors in each node in the cluster?
I'm new to Akka.NET but if I were to go about this I would probably try to create an actor that listens to cluster gossip to learn about participating nodes and perhaps record record of individual actors as well if possible otherwise a find a way of querying the individual nodes for the actors contained. Once you have references to these actors sending a message to them should be straight forward enough.
Without worrying about a built in way to discover all actors in the cluster you could build that as part of each node to have an actor designated (perhaps deployed 1:1 to a node from a router) that maintains a registry of all local actors. Maybe references to these actors could be offered up when queried or this node could just act as a proxy/gateway to broadcast messages to the local actors.
In general if you are talking about nodes behind a router, it appears that you should be able to wrap your message in a Broadcast message to get the intended effect for the routees.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.