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
  • Constructor Details

    • AggregateBasedConsistencyMarker

      public AggregateBasedConsistencyMarker(String aggregateIdentifier, long sequenceNumber)
      Construct a new consistency marker for given aggregateIdentifier and sequenceNumber.
      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

      public static AggregateBasedConsistencyMarker from(AppendCondition appendCondition)
      Constructs an AggregateBasedConsistencyMarker based of the given appendCondition. If the consistency marker of the given appendCondition is not an instance of AggregateBasedConsistencyMarker, it will attempt to create an instance that respects the condition. If such conversion is not possible, the method throws an IllegalArgumentException.
      Parameters:
      appendCondition - The condition to create an AggregateBasedConsistencyMarker for
      Returns:
      an AggregateBasedConsistencyMarker that represents the given appendCondition
      Throws:
      IllegalArgumentException - when the consistency marker of given append condition cannot be safely converted to an AggregateBasedConsistencyMarker.
    • doLowerBound

      Returns a marker containing the aggregates of both this and the given other marker, 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:
      doLowerBound in class AbstractConsistencyMarker<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 both this and the given other marker, 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:
      doUpperBound in class AbstractConsistencyMarker<AggregateBasedConsistencyMarker>
      Parameters:
      other - the other marker to combine with
      Returns:
      a marker holding the highest known position per aggregate of both markers
    • position

      public Position position()
      Description copied from interface: ConsistencyMarker
      Reduces 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, never null
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createSequencer

      Create an AggregateBasedConsistencyMarker.AggregateSequencer, initialized with values from this marker, which can increment and provide sequence numbers of multiple aggregates, and integrate the results into a new AggregateBasedConsistencyMarker.
      Returns:
      an AggregateBasedConsistencyMarker.AggregateSequencer initialized with values from this marker, never null