Class PublishedEventModelMigration
- All Implemented Interfaces:
AutoCloseable
The migration application registers only the selected Model definitions and one global EVENT consumer. It never
registers ordinary application handlers, automatic Model command handling or materialized Graph projections while
replaying. Every original global event is reduced through the normal Model replay pipeline without being published
again. Direct documents remain invisible until adopt(long) verifies the durable consumer boundary and asks
the ModelRepository to adopt them.
The consumer name must remain stable across restarts and application instances. Fluxzero fixes the consumer to
one globally ordered tracker and one synchronous handler thread; extra application instances therefore act as
failover candidates. Each event's Model commit completes before the next event is reduced and before the durable
consumer position advances. The durable position and idempotent source-event identity make restart overlap safe and
allow a reading application to coordinate legacy-event Graph injection through ModelRepository.followPublishedEventMigration(String).
A legacy Aggregate application and this migration may run concurrently as separate applications. If an old entity and its replacement Model use the same fully qualified class name, they cannot coexist in one classloader; the migration application must then be built from the new Model classes while the old application keeps running in its own process.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for one isolated published-event Model migration application. -
Method Summary
Modifier and TypeMethodDescriptionadopt(long cutoverEventIndex) Adopts all staged Model documents after the replay consumer has durably reachedcutoverEventIndex.builder()Creates a migration builder.voidclose()Returns the complete, validated Model catalog used for replay and adoption.name()Returns the stable durable consumer name shared by all migration instances.io.fluxzero.common.Registrationreplay()Starts replaying the global event log from its beginning.Returns the isolated repository used to validate migrated state before cutover.voidRuns the standard migration command-line contract: no arguments starts replay;adopt <event-index>performs the checked cutover operation and then closes the isolated application.
-
Method Details
-
builder
Creates a migration builder. -
name
Returns the stable durable consumer name shared by all migration instances. -
modelTypes
-
repository
Returns the isolated repository used to validate migrated state before cutover. -
replay
public io.fluxzero.common.Registration replay()Starts replaying the global event log from its beginning.Multiple processes may call this with the same migration name. Exactly one tracker receives the complete segment range; the others remain available for failover.
- Returns:
- a registration that stops this process' replay tracker
-
adopt
Adopts all staged Model documents after the replay consumer has durably reachedcutoverEventIndex.Run this as an explicit cutover operation. Per-Model Runtime adoption is atomic and resumable; invoking a single adoption job avoids redundant Graph rebuilds and ambiguous operator reporting.
- Parameters:
cutoverEventIndex- inclusive global event index that must already have been processed- Returns:
- the number of staged Model documents visited and adopted by this invocation
-
run
Runs the standard migration command-line contract: no arguments starts replay;adopt <event-index>performs the checked cutover operation and then closes the isolated application. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-