Record Class AggregateBasedJpaEventStorageEngineConfiguration

java.lang.Object
java.lang.Record
org.axonframework.eventsourcing.eventstore.jpa.AggregateBasedJpaEventStorageEngineConfiguration
Record Components:
persistenceExceptionResolver - The PersistenceExceptionResolver used to detect concurrency exceptions from the backing database.
finalBatchPredicate - The predicate used to recognize the terminal batch when sourcing events. Defaults to the first empty batch.
eventCoordinator - The EventCoordinator to use. Defaults to EventCoordinator.SIMPLE.
batchSize - The batch size used to retrieve events from the storage layer. Defaults to 100.
gapCleaningThreshold - The threshold of the number of gaps in a GapAwareTrackingToken before an attempt to clean them up. Defaults to an integer of 250.
maxGapOffset - The maximum distance in sequence numbers between a gap and the event with the highest known index. Defaults to an integer of 10000.
lowestGlobalSequence - Value the first expected (auto generated) global index of an AggregateEventEntry. Defaults to 1.
gapTimeout - The amount of time until a gap in a GapAwareTrackingToken may be considered timed out and thus ready for removal. Defaults to 60000ms.

public record AggregateBasedJpaEventStorageEngineConfiguration(@Nullable PersistenceExceptionResolver persistenceExceptionResolver, @Nonnull Predicate<List<? extends AggregateEventEntry>> finalBatchPredicate, @Nonnull EventCoordinator eventCoordinator, int batchSize, int gapCleaningThreshold, int maxGapOffset, long lowestGlobalSequence, int gapTimeout) extends Record
Configuration class of the AggregateBasedJpaEventStorageEngine.

This configuration class can be customized through its many builder methods. For a default configuration set use the DEFAULT constant.

Since:
4.0.0
Author:
Mateusz Nowak, Steven van Beelen
  • Field Details

  • Constructor Details

    • AggregateBasedJpaEventStorageEngineConfiguration

      public AggregateBasedJpaEventStorageEngineConfiguration(@Nullable PersistenceExceptionResolver persistenceExceptionResolver, @Nonnull Predicate<List<? extends AggregateEventEntry>> finalBatchPredicate, @Nonnull EventCoordinator eventCoordinator, int batchSize, int gapCleaningThreshold, int maxGapOffset, long lowestGlobalSequence, int gapTimeout)
      Compact constructor validating that the given key and value are not null.
  • Method Details

    • persistenceExceptionResolver

      public AggregateBasedJpaEventStorageEngineConfiguration persistenceExceptionResolver(@Nullable PersistenceExceptionResolver persistenceExceptionResolver)
      Sets the PersistenceExceptionResolver used to detect concurrency exceptions from the backing database.

      If the persistenceExceptionResolver is not specified, persistence exceptions are not explicitly resolved.

      Can be set to the SQLErrorCodesResolver, for example.

      Parameters:
      persistenceExceptionResolver - The PersistenceExceptionResolver used to detect concurrency exceptions from the backing database.
      Returns:
      A new configuration instance, for fluent interfacing.
    • finalBatchPredicate

      public AggregateBasedJpaEventStorageEngineConfiguration finalBatchPredicate(@Nonnull Predicate<List<? extends AggregateEventEntry>> finalBatchPredicate)
      Defines the predicate used to recognize the terminal batch when sourcing events.

      Defaults to the first empty batch.

      Parameters:
      finalBatchPredicate - The predicate that indicates whether a given batch is to be considered the final batch of an event stream.
      Returns:
      A new configuration instance, for fluent interfacing.
    • eventCoordinator

      public AggregateBasedJpaEventStorageEngineConfiguration eventCoordinator(@Nonnull EventCoordinator eventCoordinator)
      Defines the EventCoordinator to use.

      Defaults to EventCoordinator.SIMPLE.

      Parameters:
      eventCoordinator - The EventCoordinator to use, cannot be null.
      Returns:
      A new configuration instance, for fluent interfacing.
    • batchSize

      public AggregateBasedJpaEventStorageEngineConfiguration batchSize(int batchSize)
      Sets the batchSize specifying the number of events that should be read at each database access. When more than this number of events must be read to rebuild an aggregate's state, the events are read in batches of this size.

      Defaults to 100.

      Tip: When using a snapshotter, make sure to choose snapshot trigger and batch size such that a single batch will generally retrieve all events required to rebuild an aggregate's state.

      Parameters:
      batchSize - An int specifying the number of events that should be read at each database access.
      Returns:
      A new configuration instance, for fluent interfacing.
    • gapCleaningThreshold

      public AggregateBasedJpaEventStorageEngineConfiguration gapCleaningThreshold(int gapCleaningThreshold)
      Sets the threshold of number of gaps in a token before an attempt to clean gaps up is taken.

      Defaults to 250.

      Parameters:
      gapCleaningThreshold - an int specifying the threshold of number of gaps in a token before an attempt to clean gaps up is taken
      Returns:
      A new configuration instance, for fluent interfacing.
    • maxGapOffset

      public AggregateBasedJpaEventStorageEngineConfiguration maxGapOffset(int maxGapOffset)
      Sets the maxGapOffset specifying the maximum distance in sequence numbers between a missing event and the event with the highest known index.

      If the gap is bigger it is assumed that the missing event will not be committed to the store anymore. This event storage engine will no longer look for those events the next time a batch is fetched.

      Defaults to 10000.

      Parameters:
      maxGapOffset - An int specifying the maximum distance in sequence numbers between a missing event and the event with the highest known index.
      Returns:
      A new configuration instance, for fluent interfacing.
    • lowestGlobalSequence

      public AggregateBasedJpaEventStorageEngineConfiguration lowestGlobalSequence(long lowestGlobalSequence)
      Sets the lowestGlobalSequence specifying the first expected auto generated sequence number. For most data stores this is 1 unless the table has contained entries before.

      Defaults to 1.

      Parameters:
      lowestGlobalSequence - a long specifying the first expected auto generated sequence number
      Returns:
      A new configuration instance, for fluent interfacing.
    • gapTimeout

      public AggregateBasedJpaEventStorageEngineConfiguration gapTimeout(int gapTimeout)
      Sets the amount of time until a gap in a GapAwareTrackingToken may be considered timed out and thus ready for removal.

      This setting will affect the cleaning process of gaps. Gaps that have timed out will be removed from Tracking Tokens to improve performance of reading events.

      Defaults to 60000ms.

      Parameters:
      gapTimeout - An int specifying the amount of time in milliseconds until a 'gap' in a TrackingToken may be considered timed out.
      Returns:
      A new configuration instance, for fluent interfacing.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • persistenceExceptionResolver

      @Nullable public PersistenceExceptionResolver persistenceExceptionResolver()
      Returns the value of the persistenceExceptionResolver record component.
      Returns:
      the value of the persistenceExceptionResolver record component
    • finalBatchPredicate

      @Nonnull public Predicate<List<? extends AggregateEventEntry>> finalBatchPredicate()
      Returns the value of the finalBatchPredicate record component.
      Returns:
      the value of the finalBatchPredicate record component
    • eventCoordinator

      @Nonnull public EventCoordinator eventCoordinator()
      Returns the value of the eventCoordinator record component.
      Returns:
      the value of the eventCoordinator record component
    • batchSize

      public int batchSize()
      Returns the value of the batchSize record component.
      Returns:
      the value of the batchSize record component
    • gapCleaningThreshold

      public int gapCleaningThreshold()
      Returns the value of the gapCleaningThreshold record component.
      Returns:
      the value of the gapCleaningThreshold record component
    • maxGapOffset

      public int maxGapOffset()
      Returns the value of the maxGapOffset record component.
      Returns:
      the value of the maxGapOffset record component
    • lowestGlobalSequence

      public long lowestGlobalSequence()
      Returns the value of the lowestGlobalSequence record component.
      Returns:
      the value of the lowestGlobalSequence record component
    • gapTimeout

      public int gapTimeout()
      Returns the value of the gapTimeout record component.
      Returns:
      the value of the gapTimeout record component