Eventmodeling

Eventmodeling

Repo Quickstart Docs

What is EventModeling?

Sliceworkz EventModeling is an open source, opinionated framework in Java for building applications designed with Event Modeling: every slice of the event model becomes a feature slice in the code, and every box on the model has a home in the framework.

It builds upon the Sliceworkz Eventstore, and decides every command within a Dynamic Consistency Boundary rather than an aggregate.

The Event Modeling patterns

patternflowin the framework
State changeTrigger → Command → EventCommand, deciding on DecisionModels
State readEvents → Read model → UI/APIReadModel, live or eventually consistent
AutomationEvents → To-do list → Processor → Command → EventTodoListReadModel + Automation
 or: Event → Policy → Command → EventPolicy — whenever an event happens, issue a command
TranslationExternal event → Processor → Command → EventTranslator

And telling the outside world, in two halves:

 flowin the framework
PublisherDomain event → Outbound eventPublisher, mapping recorded facts into the published language
DispatcherOutbound event → external systemDispatcher, the outbox pattern

Features

  • Feature slices discovered by package scanning, each registering its parts per aspect — command, query, automation, projection — so a deployment can run some aspects and not others
  • DCB commands: the consistency boundary is pinned at the stream head before a command reads, and is the union of everything it decided on — conflicts are detected, never silently admitted
  • Bounded retries of optimistic-locking conflicts with executeWithRetry, and idempotency keys for safe resubmission
  • Typed entity ids and tags — an AccountId cannot be passed where a CustomerId is expected
  • Business rules with SBVR enforcement levels — rules people may override under conditions, decided by the command on history, recorded on the events, and previewable with evaluate(...) before anything is submitted
  • A ladder of read models: live, savepoint-bounded, eventually consistent in memory (PublishingReadModel), durable in SQL, seeded reads that are current without replaying, and snapshots
  • Automations that survive failure: per-item failure handling, backoff, dead letters as events, at-least-once delivery with the to-do list as the queue
  • Policies: whenever an event happens, issue a command — redelivery-safe, with an explicit choice of where to start and what a rejection means
  • Publishers and dispatchers: every outbound event traces back to the domain event it was published for
  • Ports and adapters, with monitored calls: every call to an external system reported as returned, rejected or failed
  • Leader election: automations, policies, shared read models, translators, publishers and dispatchers run on exactly one instance of a deployment, with fencing for durable read models
  • Operable: stop, restart and inspect processors on any instance, locally or through a management stream
  • Capabilities filed by audience — application code, inbound edge, operator, privacy — so each caller holds only what it needs
  • Observability through its own SPI: lifecycle events for every component, an observer for metrics and tracing, correlation ids across a whole flow
  • GDPR erasure by crypto-shredding, configured with one call

Technical

  • Pure Java 21 implementation, idle processors on virtual threads
  • Lightweight with minimal dependencies — no metrics library; bind the one you use
  • Postgres-based event storage — PostgreSQL 16+ supported, with native server-side uuidv7() on 18+ and a Java-side fallback on 16–17, auto-detected at startup
  • In-Memory storage for development and unit-testing, and file-persisted in-memory storage for local development without PostgreSQL
  • SQL-backed read models with built-in support for H2 and PostgreSQL, idempotent by design
  • Published test module: given/when/then bases for commands, aggregates, read models, automations, policies, translators, publishers, dispatchers and SQL read models — runnable against every storage backend