Event Store
The EventStore interface defines socketio4j’s distributed event synchronization layer. It provides a unified abstraction for publishing and subscribing to internal events — such as room joins, leaves, acknowledgements, session changes, and node-to-node synchronization — across one or more server instances.
Key characteristics
Unified event API — same publish/subscribe model for all backends
Typed dispatch — listeners receive strongly typed
EventMessageobjectsNode-aware filtering — implementations typically ignore self-originated events via
nodeIdPluggable transports — Kafka, Redis Streams, Hazelcast, NATS, in-memory fallback, etc.
Lifecycle control — standardized
publish,subscribe,unsubscribe,shutdown
How it works
publish→ backend-specific send viapublish0subscribe→ register event listener viasubscribe0unsubscribe→ remove listener and cleanup viaunsubscribe0shutdown→ release backend resources viashutdown0Implementations supply transport behavior through the
*0methods; the interface standardizes flow and error handling
Event routing properties
EventStoreMode
MULTI_CHANNEL (per-event streams/topics) or SINGLE_CHANNEL (unified channel)
EventStoreType
Declares transport family: STREAM, PUBSUB, LOCAL, etc.
PublishMode
Describes expected reliability: RELIABLE or UNRELIABLE
nodeId
Identifies the node; used to avoid reprocessing local events
Note:
getNodeId()provides a random ID by default. For distributed deployments, configure a stable node identity viaStoreFactory.
Advantages
👍 Swap distributed transports without code changes 👍 Centralized error logging and flow semantics 👍 Clear extension hooks for custom backends 👍 Abstracts away transport differences
Limitations
ℹ️ Delivery guarantees depend on implementation — not enforced by the interface
ℹ️ Persistence, ordering, deduplication are backend responsibilities
ℹ️ nodeId-based local filtering must be respected to avoid duplicates
Delivery Guarantees
The EventStore interface does not define delivery guarantees. Reliability, replay, and ordering depend entirely on the chosen backend (e.g., Redis Streams = at-least-once; Redis Pub/Sub = best-effort; Kafka = at-least-once; Memory = local only).
Last updated
Was this helpful?