Store Factory API

A StoreFactory selects where session data lives and which EventStore distributes events. Storage and event synchronization are independent, so you can freely combine backends.


MemoryStoreFactory

MemoryStoreFactory()

Creates a factory using in-memory storage and the default MemoryEventStore. Use for single-node or no-distribution setups.

StoreFactory sf = new MemoryStoreFactory();
// in-memory storage + local only events

MemoryStoreFactory(EventStore eventStore)

Creates a factory using in-memory storage and a custom EventStore for distributed sync.

EventStore es = new KafkaEventStore(...);
StoreFactory sf = new MemoryStoreFactory(es);
// local storage + distributed events (Kafka)

HazelcastStoreFactory

HazelcastStoreFactory(HazelcastInstance hazelcastClient)

Creates a factory using Hazelcast storage and the default HazelcastEventStore.


HazelcastStoreFactory(HazelcastInstance hazelcastClient, EventStore eventStore)

Creates a factory using Hazelcast storage and a custom EventStore backend.


RedisStoreFactory

RedisStoreFactory(RedissonClient redissonClient)

Creates a factory using Redis storage and the default RedissonPubSubEventStore (Redis Pub/Sub).


RedisStoreFactory(RedissonClient redissonClient, EventStore eventStore)

Creates a factory using Redis storage and a custom EventStore.


Mixing storage and event backends

Storage (StoreFactory)

Event (EventStore)

Example

Memory

Kafka

new MemoryStoreFactory(new KafkaEventStore(...))

Redis

NATS

new RedisStoreFactory(redis, new NatsEventStore(...))

Hazelcast

Redis Streams

new HazelcastStoreFactory(hz, new RedisStreamEventStore(...))

Memory

Memory

new MemoryStoreFactory()

Hazelcast

Kafka

new HazelcastStoreFactory(hz, new KafkaEventStore(...))


Minimal server usage


Concept summary

StoreFactory decides where per-session data lives. EventStore decides how events propagate across servers. Both are configurable and swappable, without changing application code.

Last updated

Was this helpful?