mardi 23 février 2016

Distributed Publish Subscribe in Cluster Pre Akka 2.4

I'd like to use the Distributed Publish Subscribe (DPS) pattern in an Akka remote cluster. That's as easy as using its provided by Akka implementation but if your system is constrained to use Akka versions below 2.4.0 that is not an option.

There is a Roland Kuhn's answer in SO explaining that it is legit to subscribe a remote Actor to another Actor's EventBus.

Using that, I think DPS can be implemented as follows:

  1. Subscribe all cluster members to MemberUp events in the cluster.
  2. Whenever a MemberUp is detected:

    a. Send a subscription request message to it. And use the answer (subscription acknowledgment) sender to subscribe the recently joined Actor to the local EventBus

    b. The recently joined Actor will receive the message sent at (a) and subscribe the sender to its EventBus

The question is: Do you any other pattern which could improve this approach?

Some people suggest using BroadcastRoutingLogic. Or Broadcast messages. However, in my use case, Actors can join or leave the cluster at any time.

Aucun commentaire:

Enregistrer un commentaire