Search code examples
hazelcastvert.x

When clustering a Vert.x service, do clustered EventBus handlers propagate to new joining nodes?


This is something that I haven't been able to find in the official documentation nor anywhere else yet; the situtation I propose is basically this:

  • I have a cluster of N Vert.x instances of the same service, same codebase.
  • At some point in time I register an EventBus consumer C with an address A cluster-wide. I subscribe a completion handler to get notified when the registration completes on all nodes of the cluster.
  • Everything is working fine, but now I add a new node to the cluster.

My question is actually two-fold:

  • Will the C consumer be propagated to the new-joiner? That is, if I do a eventBus().publish(A, ...) from the new-joiner, will the handler get executed?
  • Will the completion handler be called again (My guess is no, but just in case)?

Solution

  • When you add a new node to the cluster, the app will be started again on this node (if if understood correctly the situation you described).

    So on the new node, you'll register an EventBus consumer with for address A cluster-wide.

    The new node will be aware of all registrations created previously on the cluster. The previous nodes will be aware of the new registration.

    When you do eventBus().publish(A, ...) from the new-joiner, all nodes include it will invoke the consumer registered for this address.

    On the new-joiner, the completion handler will be called when the registration has been persisted. There could be a (very small) delay before the new registration is visible from other nodes because the process is asynchronous.

    The completion handler on previous nodes will not be invoked again (because the registration of the corresponding consumer already happened).