Class AggregateBasedConsistencyMarker
java.lang.Object
org.axonframework.eventsourcing.eventstore.AbstractConsistencyMarker<AggregateBasedConsistencyMarker>
org.axonframework.eventsourcing.eventstore.AggregateBasedConsistencyMarker
- All Implemented Interfaces:
ConsistencyMarker
public class AggregateBasedConsistencyMarker
extends AbstractConsistencyMarker<AggregateBasedConsistencyMarker>
ConsistencyMarker implementation that keeps track of a position per aggregate identifier. A single
AggregateBasedConsistencyMarker can track the positions of multiple Aggregates.- Since:
- 5.0.0
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classHelper class that tracks the sequence of events for different aggregates and manages the consistency marker for the aggregates. -
Field Summary
Fields inherited from interface org.axonframework.eventsourcing.eventstore.ConsistencyMarker
INFINITY, ORIGIN, RESOURCE_KEY -
Constructor Summary
ConstructorsConstructorDescriptionAggregateBasedConsistencyMarker(String aggregateIdentifier, long sequenceNumber) Construct a new consistency marker for givenaggregateIdentifierandsequenceNumber. -
Method Summary
Modifier and TypeMethodDescriptionCreate anAggregateBasedConsistencyMarker.AggregateSequencer, initialized with values from this marker, which can increment and provide sequence numbers of multiple aggregates, and integrate the results into a newAggregateBasedConsistencyMarker.Returns a marker containing the aggregates of boththisand the givenothermarker, keeping the lowest position for any aggregate both markers know about.Returns a marker containing the aggregates of boththisand the givenothermarker, keeping the highest position for any aggregate both markers know about.booleanfrom(AppendCondition appendCondition) Constructs anAggregateBasedConsistencyMarkerbased of the givenappendCondition.inthashCode()position()Reduces this consistency marker to a single position if possible.toString()Methods inherited from class org.axonframework.eventsourcing.eventstore.AbstractConsistencyMarker
lowerBound, upperBound
-
Constructor Details
-
AggregateBasedConsistencyMarker
Construct a new consistency marker for givenaggregateIdentifierandsequenceNumber.- Parameters:
aggregateIdentifier- The identifier of the aggregate to contain in the marker.sequenceNumber- The sequence number of the last seen event of the aggregate.
-
-
Method Details
-
from
Constructs anAggregateBasedConsistencyMarkerbased of the givenappendCondition. If the consistency marker of the givenappendConditionis not an instance ofAggregateBasedConsistencyMarker, it will attempt to create an instance that respects the condition. If such conversion is not possible, the method throws anIllegalArgumentException.- Parameters:
appendCondition- The condition to create anAggregateBasedConsistencyMarkerfor- Returns:
- an
AggregateBasedConsistencyMarkerthat represents the givenappendCondition - Throws:
IllegalArgumentException- when the consistency marker of given append condition cannot be safely converted to anAggregateBasedConsistencyMarker.
-
doLowerBound
Returns a marker containing the aggregates of boththisand the givenothermarker, keeping the lowest position for any aggregate both markers know about.Positions of distinct aggregates are independent of one another, so an aggregate that only one of the two markers knows about keeps its position in the result. Dropping it would reset that aggregate to the start of its event stream, which both loses conflict detection for the aggregate and restarts its sequence numbers at zero.
- Specified by:
doLowerBoundin classAbstractConsistencyMarker<AggregateBasedConsistencyMarker>- Parameters:
other- the other marker to combine with- Returns:
- a marker holding the lowest known position per aggregate of both markers
-
doUpperBound
Returns a marker containing the aggregates of boththisand the givenothermarker, keeping the highest position for any aggregate both markers know about.Positions of distinct aggregates are independent of one another, so an aggregate that only one of the two markers knows about keeps its position in the result. Dropping it would reset that aggregate to the start of its event stream, which both loses conflict detection for the aggregate and restarts its sequence numbers at zero.
- Specified by:
doUpperBoundin classAbstractConsistencyMarker<AggregateBasedConsistencyMarker>- Parameters:
other- the other marker to combine with- Returns:
- a marker holding the highest known position per aggregate of both markers
-
position
Description copied from interface:ConsistencyMarkerReduces this consistency marker to a single position if possible. Note that this must always succeed if the marker was created based on a single sourcing. The position returned is guaranteed to be suitable to resume an earlier sourcing from the exact position it ended at.- Returns:
- a
Position, nevernull
-
equals
-
hashCode
public int hashCode() -
toString
-
createSequencer
Create anAggregateBasedConsistencyMarker.AggregateSequencer, initialized with values from this marker, which can increment and provide sequence numbers of multiple aggregates, and integrate the results into a newAggregateBasedConsistencyMarker.- Returns:
- an
AggregateBasedConsistencyMarker.AggregateSequencerinitialized with values from this marker, nevernull
-