Class ClusterBus

java.lang.Object
com.kingsrook.qqq.backend.core.cluster.ClusterBus

public final class ClusterBus extends Object
Cluster control events (spec 2026-10-15-cluster-ha-design): when a node changes something other nodes hold in memory - a session ends, the meta data overlay changes, a cached record is edited - it publishes an event. Every node (this one at once, the others through the transport) runs the handlers registered for that event type. A node ignores its own events coming back from the transport. Caches keep short TTLs as a safety net in case an event is lost. Handlers are global (ClusterBus.on) and run as the system user of the instance the event arrived on.
  • Method Details

    • on

      public static void on(String type, BiConsumer<QInstance,ClusterEvent> handler)
      Register a handler for an event type (it runs on every node).
    • connect

      public static void connect(QInstance instance)
      Connect an instance to its transport (idempotent). Call at startup, so this node receives events before it publishes any.
    • publish

      public static void publish(QInstance instance, ClusterEvent event)
      Publish an event: handled on this node now, and sent to the others.
    • close

      public static void close(QInstance instance)
      Disconnect an instance (shutdown, tests).