Class SnapshotSourcingConfigurationEnhancer

java.lang.Object
org.axonframework.eventsourcing.configuration.SnapshotSourcingConfigurationEnhancer
All Implemented Interfaces:
ConfigurationEnhancer

@RegistrationScope(scope=CURRENT) public class SnapshotSourcingConfigurationEnhancer extends Object implements ConfigurationEnhancer
A ConfigurationEnhancer making the EventStorageEngine support the snapshot sourcing strategy, by decorating it with the configured SnapshotStore through SnapshotCapableEventStorageEngine.decorate(EventStorageEngine, SnapshotStore).

The engine is left as is when no SnapshotStore is configured, and when it is the configured SnapshotStore itself. The latter resolves the snapshot within its own source call, in a single round trip, which decorating would undo.

Registered by EventSourcingConfigurationDefaults, so applications registering those defaults manually receive it as well. It is deliberately not contributed through the ServiceLoader, unlike its sibling enhancers, to keep that single registration channel. Registered for the current registry only, since the defaults registering it are copied into every module registry and would otherwise register it there a second time.

A storage topology composing snapshot sourcing itself disables this enhancer, taking over that responsibility:


 configurer.componentRegistry(
         registry -> registry.disableEnhancer(SnapshotSourcingConfigurationEnhancer.class)
 );
 
An engine routing source to one engine per shard, tenant, or region is the case this exists for: the shard is only known once a message is inspected, so decorating the routing engine would resolve snapshots before then, and the engines it routes to would never receive the snapshot sourcing strategy. Such a topology composes each of its engines with that engine's own snapshot store instead, through the same decorate operation.

Disabling this enhancer without composing snapshot sourcing elsewhere leaves snapshots being written while never being read: sourcing then replays an entity's full event history.

Since:
5.3.0
Author:
Laura Devriendt
  • Field Details

    • ENHANCER_ORDER

      public static final int ENHANCER_ORDER
      The order of this enhancer compared to others, equal to 10 positions after EventSourcingConfigurationDefaults (thus, EventSourcingConfigurationDefaults.ENHANCER_ORDER + 10).

      What this order governs is the window in which this enhancer can still be disabled: a disable is only recorded while the enhancer has not been invoked yet, and is otherwise reported as having no effect. Running late therefore leaves every earlier-ordered enhancer free to take over snapshot composition.

      See Also:
  • Constructor Details

    • SnapshotSourcingConfigurationEnhancer

      public SnapshotSourcingConfigurationEnhancer()
  • Method Details

    • order

      public int order()
      Description copied from interface: ConfigurationEnhancer
      Returns the relative order this enhancer should be invoked in, compared to other instances.

      Use lower (negative) values for enhancers providing sensible defaults, and higher values for enhancers that should be able to override values potentially previously set. Defaults to 0 when not set.

      Specified by:
      order in interface ConfigurationEnhancer
      Returns:
      The order in which this enhancer should be invoked.
    • enhance

      public void enhance(ComponentRegistry registry)
      Description copied from interface: ConfigurationEnhancer
      Enhances the given registry with, for example, additional components and decorators.
      Specified by:
      enhance in interface ConfigurationEnhancer
      Parameters:
      registry - The registry instance to enhance.