Record Class AggregateBasedJpaEventStorageEngineConfiguration
- Record Components:
persistenceExceptionResolver- ThePersistenceExceptionResolverused to detect concurrency exceptions from the backing database.finalBatchPredicate- The predicate used to recognize the terminal batch whensourcingevents. Defaults to the first empty batch.eventCoordinator- TheEventCoordinatorto use. Defaults toEventCoordinator.SIMPLE.batchSize- The batch size used to retrieve events from the storage layer. Defaults to100.gapCleaningThreshold- The threshold of the number of gaps in aGapAwareTrackingTokenbefore an attempt to clean them up. Defaults to an integer of250.maxGapOffset- The maximum distance in sequence numbers between a gap and the event with the highest known index. Defaults to an integer of10000.lowestGlobalSequence- Value the first expected (auto generated)global indexof anAggregateEventEntry. Defaults to1.gapTimeout- The amount of time until a gap in aGapAwareTrackingTokenmay be considered timed out and thus ready for removal. Defaults to60000ms.
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final AggregateBasedJpaEventStorageEngineConfigurationA default instance of theAggregateBasedJpaEventStorageEngineConfiguration. -
Constructor Summary
ConstructorsConstructorDescriptionAggregateBasedJpaEventStorageEngineConfiguration(PersistenceExceptionResolver persistenceExceptionResolver, Predicate<List<? extends AggregateEventEntry>> finalBatchPredicate, EventCoordinator eventCoordinator, int batchSize, int gapCleaningThreshold, int maxGapOffset, long lowestGlobalSequence, int gapTimeout) Compact constructor validating that the givenkeyandvalueare notnull. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thebatchSizerecord component.batchSize(int batchSize) Sets thebatchSizespecifying the number of events that should be read at each database access.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theeventCoordinatorrecord component.eventCoordinator(EventCoordinator eventCoordinator) Defines theEventCoordinatorto use.Predicate<List<? extends AggregateEventEntry>> Returns the value of thefinalBatchPredicaterecord component.finalBatchPredicate(Predicate<List<? extends AggregateEventEntry>> finalBatchPredicate) Defines the predicate used to recognize the terminal batch whensourcingevents.intReturns the value of thegapCleaningThresholdrecord component.gapCleaningThreshold(int gapCleaningThreshold) Sets the threshold of number of gaps in a token before an attempt to clean gaps up is taken.intReturns the value of thegapTimeoutrecord component.gapTimeout(int gapTimeout) Sets the amount of time until a gap in aGapAwareTrackingTokenmay be considered timed out and thus ready for removal.final inthashCode()Returns a hash code value for this object.longReturns the value of thelowestGlobalSequencerecord component.lowestGlobalSequence(long lowestGlobalSequence) Sets thelowestGlobalSequencespecifying the first expected auto generated sequence number.intReturns the value of themaxGapOffsetrecord component.maxGapOffset(int maxGapOffset) Sets themaxGapOffsetspecifying the maximum distance in sequence numbers between a missing event and the event with the highest known index.Returns the value of thepersistenceExceptionResolverrecord component.persistenceExceptionResolver(PersistenceExceptionResolver persistenceExceptionResolver) Sets thePersistenceExceptionResolverused to detect concurrency exceptions from the backing database.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT
A default instance of theAggregateBasedJpaEventStorageEngineConfiguration.
-
-
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 givenkeyandvalueare notnull.
-
-
Method Details
-
persistenceExceptionResolver
public AggregateBasedJpaEventStorageEngineConfiguration persistenceExceptionResolver(@Nullable PersistenceExceptionResolver persistenceExceptionResolver) Sets thePersistenceExceptionResolverused to detect concurrency exceptions from the backing database.If the
persistenceExceptionResolveris not specified, persistence exceptions are not explicitly resolved.Can be set to the
SQLErrorCodesResolver, for example.- Parameters:
persistenceExceptionResolver- ThePersistenceExceptionResolverused 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 whensourcingevents.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 theEventCoordinatorto use.Defaults to
EventCoordinator.SIMPLE.- Parameters:
eventCoordinator- TheEventCoordinatorto use, cannot benull.- Returns:
- A new configuration instance, for fluent interfacing.
-
batchSize
Sets thebatchSizespecifying 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- Anintspecifying 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- anintspecifying 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
Sets themaxGapOffsetspecifying 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- Anintspecifying 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 thelowestGlobalSequencespecifying 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- alongspecifying the first expected auto generated sequence number- Returns:
- A new configuration instance, for fluent interfacing.
-
gapTimeout
Sets the amount of time until a gap in aGapAwareTrackingTokenmay 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- Anintspecifying 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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
persistenceExceptionResolver
Returns the value of thepersistenceExceptionResolverrecord component.- Returns:
- the value of the
persistenceExceptionResolverrecord component
-
finalBatchPredicate
Returns the value of thefinalBatchPredicaterecord component.- Returns:
- the value of the
finalBatchPredicaterecord component
-
eventCoordinator
Returns the value of theeventCoordinatorrecord component.- Returns:
- the value of the
eventCoordinatorrecord component
-
batchSize
public int batchSize()Returns the value of thebatchSizerecord component.- Returns:
- the value of the
batchSizerecord component
-
gapCleaningThreshold
public int gapCleaningThreshold()Returns the value of thegapCleaningThresholdrecord component.- Returns:
- the value of the
gapCleaningThresholdrecord component
-
maxGapOffset
public int maxGapOffset()Returns the value of themaxGapOffsetrecord component.- Returns:
- the value of the
maxGapOffsetrecord component
-
lowestGlobalSequence
public long lowestGlobalSequence()Returns the value of thelowestGlobalSequencerecord component.- Returns:
- the value of the
lowestGlobalSequencerecord component
-
gapTimeout
public int gapTimeout()Returns the value of thegapTimeoutrecord component.- Returns:
- the value of the
gapTimeoutrecord component
-