Class PostgresClusterEventBus

java.lang.Object
com.onec.cluster.pg.PostgresClusterEventBus
All Implemented Interfaces:
ClusterEventBus, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

public class PostgresClusterEventBus extends Object implements ClusterEventBus, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
ClusterEventBus backed by Postgres LISTEN/NOTIFY — the default cross-node transport, needing no infrastructure beyond the database the app already uses.

Publish is a short pooled SELECT pg_notify(channel, json). Receive runs on one daemon thread holding a dedicated connection that LISTENs on the channel and blocks in PGConnection.getNotifications(int); on a dropped connection it reconnects with capped exponential backoff. Events the node published itself are filtered out by ClusterEvent.originNodeId() (Postgres echoes a NOTIFY back to the publisher's own LISTEN, and the publisher already fanned the change out to its local SSE clients).

This is a best-effort live-UI signal: a notice missed during a reconnect is acceptable (browsers re-fetch on their next interaction). The held listener connection costs one slot from the datasource pool for the bus's lifetime.