Class AbstractTokenEntry<T>
java.lang.Object
org.axonframework.eventhandling.tokenstore.AbstractTokenEntry<T>
- Type Parameters:
T- The serialized data type of the token
- Direct Known Subclasses:
GenericTokenEntry
Abstract base class of a JPA entry containing a serialized tracking token belonging to a given process.
For use with Jakarta/Hibernate 6 use
TokenEntry instead.- Author:
- Rene de Waele
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor required for JPAprotectedAbstractTokenEntry(TrackingToken token, Serializer serializer, Class<T> contentType) Initializes a new token entry for giventoken,processandsegment.protectedAbstractTokenEntry(T token, String tokenType, String timestamp, String owner) Initializes a token entry from existing data. -
Method Summary
Modifier and TypeMethodDescriptionbooleanclaim(String owner, TemporalAmount claimTimeout) Attempt to claim ownership of this token.getOwner()Returns the identifier of the process (JVM) having a claim on this token, ornullif the token isn't claimed.abstract StringReturns the name of the process to which this token belongs.abstract intReturns the segment index of the process to which this token belongs.Returns the serialized token.getToken(Serializer serializer) Returns the token, deserializing it with givenserializerReturns theSerializedTypeof the serialized token, ornullif no token is stored by this entry.booleanmayClaim(String owner, TemporalAmount claimTimeout) Check if givenownermay claim this token.booleanreleaseClaim(String owner) Release any claim of ownership currently active on this Token, if owned by the givenowner.Returns the storage timestamp of this token entry.Returns the storage timestamp of this token entry as a String.abstract voidupdateToken(TrackingToken token, Serializer serializer) Update this entry with the giventoken, serializing it using givenserializer.protected final voidupdateToken(TrackingToken token, Serializer serializer, Class<T> contentType) Update the token data to the giventoken, using givenserializerto serialize it to the givencontentType.
-
Field Details
-
clock
The clock used to persist timestamps in this entry. Defaults to UTC system time.
-
-
Constructor Details
-
AbstractTokenEntry
Initializes a new token entry for giventoken,processandsegment. The givenserializercan be used to serialize the token before it is stored.- Parameters:
token- The tracking token to storeserializer- The serializer to use when storing a serialized tokencontentType- The content type after serialization
-
AbstractTokenEntry
Initializes a token entry from existing data.- Parameters:
token- the serialized tokentokenType- the serialized type of the tokentimestamp- the timestamp of the tokenowner- the owner of the token
-
AbstractTokenEntry
protected AbstractTokenEntry()Default constructor required for JPA
-
-
Method Details
-
getSerializedToken
Returns the serialized token.- Returns:
- the serialized token stored in this entry
-
getToken
Returns the token, deserializing it with givenserializer- Parameters:
serializer- The serialize to deserialize the token with- Returns:
- the deserialized token stored in this entry
-
getTokenType
Returns theSerializedTypeof the serialized token, ornullif no token is stored by this entry.- Returns:
- the serialized type of the token, or
nullif no token is stored by this entry
-
timestamp
Returns the storage timestamp of this token entry.- Returns:
- The storage timestamp
-
timestampAsString
Returns the storage timestamp of this token entry as a String.- Returns:
- The storage timestamp as string
-
updateToken
Update this entry with the giventoken, serializing it using givenserializer.- Parameters:
token- The token to update the entry withserializer- The serializer to serialize data with
-
getProcessorName
Returns the name of the process to which this token belongs.- Returns:
- the process name
-
getSegment
public abstract int getSegment()Returns the segment index of the process to which this token belongs.- Returns:
- the segment index
-
claim
Attempt to claim ownership of this token. When successful, this method returnstrue, otherwisefalse. When a claim fails, this token should not be used, as it is already being used in another process.If a claim exists, but it is older than given
claimTimeout, the claim may be 'stolen'.- Parameters:
owner- The name of the current node, to register as owner. This name must be unique for multiple instances of the same logical processorclaimTimeout- The time after which a claim may be 'stolen' from its current owner- Returns:
trueif the claim succeeded, otherwise false
-
mayClaim
Check if givenownermay claim this token.- Parameters:
owner- The name of the current node, to register as owner. This name must be unique for multiple instances of the same logical processorclaimTimeout- The time after which a claim may be 'stolen' from its current owner- Returns:
trueif the claim may be made,falseotherwise
-
releaseClaim
Release any claim of ownership currently active on this Token, if owned by the givenowner.- Parameters:
owner- The name of the current node, which was registered as the owner- Returns:
trueof the claim was successfully released, orfalseif the token has been claimed by another owner.
-
getOwner
Returns the identifier of the process (JVM) having a claim on this token, ornullif the token isn't claimed.- Returns:
- the process (JVM) that claimed this token
-
updateToken
Update the token data to the giventoken, using givenserializerto serialize it to the givencontentType.- Parameters:
token- The token representing the state to update toserializer- The serializer to update token tocontentType- The type of data to represent the serialized data in
-