3

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.

  1. What am I missing?
  2. Can someone point me to a working demo?

Thanks

guy kolbis
  • 41
  • 3
  • Are you using Akka.Serialization.Wire as default serializer? You can see working example in [examples section](https://github.com/akkadotnet/akka.net/tree/dev/src/examples/Cluster/ClusterTools). – Bartosz Sypytkowski Mar 28 '16 at 19:18
  • Hi, thanks for the reply. yes I am using wire as serializer. the link provided does not implement pub/sub. – guy kolbis Mar 30 '16 at 06:39

1 Answers1

1

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.

jpierson
  • 16,435
  • 14
  • 105
  • 149