Class MultiSourceTrackingToken
java.lang.Object
org.axonframework.messaging.eventstreaming.MultiSourceTrackingToken
- All Implemented Interfaces:
TrackingToken
A
TrackingToken implementation combining several TrackingTokens into one. Used to keep track of
several event sources at once, like the MultiStreamableEventSource.- Since:
- 4.2
- Author:
- Greg Woods
-
Field Summary
Fields inherited from interface org.axonframework.messaging.eventhandling.processing.streaming.token.TrackingToken
FIRST, LATEST, RESOURCE_KEY -
Constructor Summary
ConstructorsConstructorDescriptionMultiSourceTrackingToken(Map<String, TrackingToken> trackingTokens) Construct a newMultiSourceTrackingTokenfrom a map of existing tokens. -
Method Summary
Modifier and TypeMethodDescriptionadvancedTo(String streamName, TrackingToken newTokenForStream) Advances a single token within the tokenMapbooleancovers(TrackingToken other) Compares this token tootherchecking each member token with its counterpart to see if they are covered in theothertoken.booleangetTokenForStream(String streamName) Return the tracking token for an individual streamReturns the map containing the constituent tokens.inthashCode()lowerBound(TrackingToken other) Compares this token tootherby comparing each member token with its counterpart in theothertoken.position()Returns the sum of all positions of the constituent tracking tokens.booleansamePositionAs(TrackingToken other) Indicates whetherthistoken is at the exact same spot in the event stream as theothertoken.toString()upperBound(TrackingToken other) Compares this token tootherby comparing each member token with its counterpart in theothertoken.
-
Constructor Details
-
MultiSourceTrackingToken
@ConstructorProperties("trackingTokens") public MultiSourceTrackingToken(Map<String, TrackingToken> trackingTokens) Construct a newMultiSourceTrackingTokenfrom a map of existing tokens.- Parameters:
trackingTokens- the map of tokens which make up theMultiSourceTrackingToken
-
-
Method Details
-
lowerBound
Compares this token tootherby comparing each member token with its counterpart in theothertoken. If the two tokens contain different number of constituent tokens, or have the same number but different names, then these twoMultiSourceTrackingTokens must be tracking differentMultiStreamableEventSources.- Specified by:
lowerBoundin interfaceTrackingToken- Parameters:
other- The token to compare to this one- Returns:
- token representing the lower bound of both tokens
-
upperBound
Compares this token tootherby comparing each member token with its counterpart in theothertoken. If the two tokens contain different number of constituent tokens, or have the same number but different names, then these twoMultiSourceTrackingTokens must be tracking differentMultiStreamableEventSources.- Specified by:
upperBoundin interfaceTrackingToken- Parameters:
other- The token to compare this token to- Returns:
- a token that represents the furthest position of this or the other streams
-
covers
Compares this token tootherchecking each member token with its counterpart to see if they are covered in theothertoken. If the two tokens contain different number of constituent tokens, or have the same number but different names, then these twoMultiSourceTrackingTokens must be tracking differentMultiStreamableEventSources.- Specified by:
coversin interfaceTrackingToken- Parameters:
other- The token to compare to this one- Returns:
trueif this token covers the other, otherwisefalse
-
samePositionAs
Description copied from interface:TrackingTokenIndicates whetherthistoken is at the exact same spot in the event stream as theothertoken.This method is particularly useful when comparing tokens from different points in time, such as during replay detection, where token implementations may naturally differ.
By default, this method checks bidirectional coverage:
this.covers(other) && other.covers(this), which ensures both tokens are at the same position.- Specified by:
samePositionAsin interfaceTrackingToken- Parameters:
other- The token to validate againstthistoken.- Returns:
trueif this token is at the same location as the other token, otherwisefalse. Returnsfalseifotherisnull.- See Also:
-
advancedTo
Advances a single token within the tokenMap- Parameters:
streamName- the stream/source which is being advancednewTokenForStream- the token representing the new position of the stream- Returns:
- the token representing the current processing position of all streams.
-
getTokenForStream
Return the tracking token for an individual stream- Parameters:
streamName- the name of the stream for the tracking token- Returns:
- the tracking token for the stream
-
getTrackingTokens
Returns the map containing the constituent tokens.- Returns:
- the map containing the constituent tokens.
-
position
Returns the sum of all positions of the constituent tracking tokens.- Specified by:
positionin interfaceTrackingToken- Returns:
- Sum of all positions of the constituent tracking tokens.
-
equals
-
hashCode
public int hashCode() -
toString
-